summaryrefslogtreecommitdiff
path: root/lib/libfrr.c
diff options
context:
space:
mode:
authorQuentin Young <qlyoung@nvidia.com>2020-11-30 17:37:18 -0500
committerQuentin Young <qlyoung@nvidia.com>2020-12-01 18:37:14 -0500
commite4e0229aba2b90d93bf681cc4e309c93f7cff61f (patch)
tree3885492f543d13ae42dbe47b83fe3a5b38368027 /lib/libfrr.c
parentfa22080d22e1e4e69f7bed6d041083df1b85b4b7 (diff)
lib: add support for scripts directory
Specify default via --with-scriptdir at compile time, override default with --scriptdir at runtime. If unspecified, it's {sysconfdir}/scripts (usually /etc/frr/scripts) Signed-off-by: Quentin Young <qlyoung@nvidia.com>
Diffstat (limited to 'lib/libfrr.c')
-rw-r--r--lib/libfrr.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/libfrr.c b/lib/libfrr.c
index 05e6cf36e4..b83883779c 100644
--- a/lib/libfrr.c
+++ b/lib/libfrr.c
@@ -56,6 +56,7 @@ char frr_vtydir[256];
const char frr_dbdir[] = DAEMON_DB_DIR;
#endif
const char frr_moduledir[] = MODULE_PATH;
+const char frr_scriptdir[] = SCRIPT_PATH;
char frr_protoname[256] = "NONE";
char frr_protonameinst[256] = "NONE";
@@ -101,6 +102,7 @@ static void opt_extend(const struct optspec *os)
#define OPTION_DB_FILE 1006
#define OPTION_LOGGING 1007
#define OPTION_LIMIT_FDS 1008
+#define OPTION_SCRIPTDIR 1009
static const struct option lo_always[] = {
{"help", no_argument, NULL, 'h'},
@@ -111,6 +113,7 @@ static const struct option lo_always[] = {
{"pathspace", required_argument, NULL, 'N'},
{"vty_socket", required_argument, NULL, OPTION_VTYSOCK},
{"moduledir", required_argument, NULL, OPTION_MODULEDIR},
+ {"scriptdir", required_argument, NULL, OPTION_SCRIPTDIR},
{"log", required_argument, NULL, OPTION_LOG},
{"log-level", required_argument, NULL, OPTION_LOGLEVEL},
{"tcli", no_argument, NULL, OPTION_TCLI},
@@ -127,6 +130,7 @@ static const struct optspec os_always = {
" -N, --pathspace Insert prefix into config & socket paths\n"
" --vty_socket Override vty socket path\n"
" --moduledir Override modules directory\n"
+ " --scriptdir Override scripts directory\n"
" --log Set Logging to stdout, syslog, or file:<name>\n"
" --log-level Set Logging Level to use, debug, info, warn, etc\n"
" --tcli Use transaction-based CLI\n"
@@ -534,6 +538,14 @@ static int frr_opt(int opt)
}
di->module_path = optarg;
break;
+ case OPTION_SCRIPTDIR:
+ if (di->script_path) {
+ fprintf(stderr, "--scriptdir option specified more than once!\n");
+ errors++;
+ break;
+ }
+ di->script_path = optarg;
+ break;
case OPTION_TCLI:
di->cli_mode = FRR_CLI_TRANSACTIONAL;
break;
@@ -719,7 +731,7 @@ struct thread_master *frr_init(void)
frr_pthread_init();
#ifdef HAVE_SCRIPTING
- frrscript_init();
+ frrscript_init(di->script_path ? di->script_path : frr_scriptdir);
#endif
log_ref_init();