diff --git a/CHANGELOG.md b/CHANGELOG.md index a80300f9..0f780790 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ ### Major New features ### API changes on existing features (you may need to change your code) +* clixon_restconf and clixon_netconf now take -D as command-line option instead of just -D + * This aligns to clixon_cli and clixon_backend * Application command option -S to clixon_netconf is obsolete. Use `clixon_netconf -l s` instead. ### Minor changes diff --git a/apps/cli/cli_main.c b/apps/cli/cli_main.c index 7ecf20f8..f2d2de3a 100644 --- a/apps/cli/cli_main.c +++ b/apps/cli/cli_main.c @@ -206,7 +206,7 @@ usage(clicon_handle h, "where commands is a CLI command or options passed to the main plugin\n" "where options are\n" "\t-h \t\tHelp\n" - "\t-D \tDebug\n" + "\t-D \tDebug level\n" "\t-f \tConfig-file (mandatory)\n" "\t-x\t\tDump configuration file as XML on stdout (migration utility)\n" "\t-F \tRead commands from file (default stdin)\n" diff --git a/apps/netconf/netconf_main.c b/apps/netconf/netconf_main.c index 817c2c82..77db0176 100644 --- a/apps/netconf/netconf_main.c +++ b/apps/netconf/netconf_main.c @@ -296,7 +296,7 @@ usage(clicon_handle h, fprintf(stderr, "usage:%s\n" "where options are\n" "\t-h\t\tHelp\n" - "\t-D\t\tDebug\n" + "\t-D \tDebug level\n" "\t-q\t\tQuiet: dont send hello prompt\n" "\t-f \tConfiguration file (mandatory)\n" "\t-l > \tLog on std(e)rr, std(o)ut, (s)yslog, (f)ile (syslog is default)\n" @@ -345,7 +345,8 @@ main(int argc, usage(h, argv[0]); break; case 'D' : /* debug */ - debug = 1; + if (sscanf(optarg, "%d", &debug) != 1) + usage(h, argv[0]); break; case 'f': /* override config file */ if (!strlen(optarg)) diff --git a/apps/restconf/README.md b/apps/restconf/README.md index ce077300..f3f0c71f 100644 --- a/apps/restconf/README.md +++ b/apps/restconf/README.md @@ -66,7 +66,7 @@ curl -sX POST -d '{"interfaces":{"interface":{"name":"eth1","type":"eth","enable Start the restconf fastcgi program with debug flag: ``` -sudo su -c "/www-data/clixon_restconf -Df /usr/local/etc/example.xml" -s /bin/sh www-data +sudo su -c "/www-data/clixon_restconf -D 1 f /usr/local/etc/example.xml" -s /bin/sh www-data ``` Look at syslog: ``` diff --git a/apps/restconf/restconf_main.c b/apps/restconf/restconf_main.c index be5bfd67..2a9d8ae5 100644 --- a/apps/restconf/restconf_main.c +++ b/apps/restconf/restconf_main.c @@ -39,7 +39,7 @@ * sudo apt-get install libfcgi-dev * gcc -o fastcgi fastcgi.c -lfcgi - * sudo su -c "/www-data/clixon_restconf -Df /usr/local/etc/example.xml " -s /bin/sh www-data + * sudo su -c "/www-data/clixon_restconf -D 1 -f /usr/local/etc/example.xml " -s /bin/sh www-data * This is the interface: * api/data/profile=/metric= PUT data:enable= @@ -74,7 +74,7 @@ #include "restconf_methods.h" /* Command line options to be passed to getopt(3) */ -#define RESTCONF_OPTS "hDf:l:p:y:a:u:" +#define RESTCONF_OPTS "hD:f:l:p:y:a:u:" /* RESTCONF enables deployments to specify where the RESTCONF API is located. The client discovers this by getting the "/.well-known/host-meta" @@ -488,7 +488,7 @@ usage(clicon_handle h, fprintf(stderr, "usage:%s [options]\n" "where options are\n" "\t-h \t\tHelp\n" - "\t-D \t\tDebug. Log to syslog\n" + "\t-D \tDebug level\n" "\t-f \tConfiguration file (mandatory)\n" "\t-l > \tLog on (s)yslog, (f)ile (syslog is default)\n" "\t-d \tSpecify restconf plugin directory dir (default: %s)\n" @@ -533,7 +533,8 @@ main(int argc, usage(h, argv[0]); break; case 'D' : /* debug */ - debug = 1; + if (sscanf(optarg, "%d", &debug) != 1) + usage(h, argv[0]); break; case 'f': /* override config file */ if (!strlen(optarg)) diff --git a/apps/restconf/restconf_methods.c b/apps/restconf/restconf_methods.c index d75dafd9..6a1712f6 100644 --- a/apps/restconf/restconf_methods.c +++ b/apps/restconf/restconf_methods.c @@ -39,7 +39,7 @@ * sudo apt-get install libfcgi-dev * gcc -o fastcgi fastcgi.c -lfcgi - * sudo su -c "/www-data/clixon_restconf -Df /usr/local/etc/example.xml " -s /bin/sh www-data + * sudo su -c "/www-data/clixon_restconf -D 1 f /usr/local/etc/example.xml " -s /bin/sh www-data * This is the interface: * api/data/profile=/metric= PUT data:enable= diff --git a/test/lib.sh b/test/lib.sh index 1b58a404..2e7d0549 100755 --- a/test/lib.sh +++ b/test/lib.sh @@ -15,8 +15,8 @@ clixon_cli=clixon_cli clixon_netconf=clixon_netconf # How to run restconf stand-alone and using valgrind -#sudo su -c "/www-data/clixon_restconf -f $cfg -D" -s /bin/sh www-data -#sudo su -c "valgrind --leak-check=full --show-leak-kinds=all /www-data/clixon_restconf -f $cfg -D" -s /bin/sh www-data +#sudo su -c "/www-data/clixon_restconf -f $cfg -D 1" -s /bin/sh www-data +#sudo su -c "valgrind --leak-check=full --show-leak-kinds=all /www-data/clixon_restconf -f $cfg -D 1" -s /bin/sh www-data #clixon_backend="valgrind --leak-check=full --show-leak-kinds=all clixon_backend" clixon_backend=clixon_backend diff --git a/test/test_perf.sh b/test/test_perf.sh index 7fe241a0..b5703683 100755 --- a/test/test_perf.sh +++ b/test/test_perf.sh @@ -72,7 +72,7 @@ new "kill old restconf daemon" sudo pkill -u www-data clixon_restconf new "start restconf daemon" -sudo start-stop-daemon -S -q -o -b -x /www-data/clixon_restconf -d /www-data -c www-data -- -f $cfg -y $fyang # -D +sudo start-stop-daemon -S -q -o -b -x /www-data/clixon_restconf -d /www-data -c www-data -- -f $cfg -y $fyang # -D 1 sleep 1 diff --git a/test/test_restconf.sh b/test/test_restconf.sh index 7201eb74..c2fc32b1 100755 --- a/test/test_restconf.sh +++ b/test/test_restconf.sh @@ -92,7 +92,7 @@ new "kill old restconf daemon" sudo pkill -u www-data clixon_restconf new "start restconf daemon" -sudo start-stop-daemon -S -q -o -b -x /www-data/clixon_restconf -d /www-data -c www-data -- -f $cfg -y $fyang -D +sudo start-stop-daemon -S -q -o -b -x /www-data/clixon_restconf -d /www-data -c www-data -- -f $cfg -y $fyang # -D 1 sleep 1 diff --git a/test/test_restconf2.sh b/test/test_restconf2.sh index dfd7a265..1065cbee 100755 --- a/test/test_restconf2.sh +++ b/test/test_restconf2.sh @@ -60,7 +60,7 @@ new "kill old restconf daemon" sudo pkill -u www-data clixon_restconf new "start restconf daemon" -sudo start-stop-daemon -S -q -o -b -x /www-data/clixon_restconf -d /www-data -c www-data -- -f $cfg # -D +sudo start-stop-daemon -S -q -o -b -x /www-data/clixon_restconf -d /www-data -c www-data -- -f $cfg # -D 1 sleep 1