]> git.puffer.fish Git - mirror/frr.git/commitdiff
[daemon startup] Add --dry-run/-C argument to daemons, to check config file syntax
authorPaul Jakma <paul.jakma@sun.com>
Sun, 15 Oct 2006 23:35:57 +0000 (23:35 +0000)
committerPaul Jakma <paul.jakma@sun.com>
Sun, 15 Oct 2006 23:35:57 +0000 (23:35 +0000)
2006-10-04 Oliver Hookins <ohookins@gmail.com>

* bgpd/bgp_main.c: Add configuration check option, with
'-C' rather than '-c' for consistency between daemons.
* isisd/isis_main.c: ditto
* ospf6d/ospf6_main.c: ditto
* ospfd/ospf_main.c: ditto
* ripngd/ripng_main.c: ditto
* vtysh/vtysh_main.c: ditto
* ripd/rip_main.c: Change the config check option to
'-C' and tidy up the code.
* zebra/main.c: ditto

2006-10-04 Stergiakis Alexandros <astergiakis@antcor.com>

* ripd/rip_main.c: This trivial patch introduces a new
  command-line option '-c', which instructs zebra/ripd
  to check its configuration file for validity, print
  any error message, and then exit. This is useful when
  the configuration file is edited by hand or otherwise,
  and you simply want to validate it without any other
  effect.
* zebra/main.c: ditto

ChangeLog
bgpd/bgp_main.c
isisd/isis_main.c
ospf6d/ospf6_main.c
ospfd/ospf_main.c
ripd/rip_main.c
ripngd/ripng_main.c
vtysh/vtysh_main.c
zebra/main.c

index 4763e5cbe382e459eb52c9efb201496b198312b6..053c413b6d3557889bc88a1f282e5134c43c4772 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,27 @@
+2006-10-04 Oliver Hookins <ohookins@gmail.com>
+
+       * bgpd/bgp_main.c: Add configuration check option, with
+       '-C' rather than '-c' for consistency between daemons.
+       * isisd/isis_main.c: ditto
+       * ospf6d/ospf6_main.c: ditto
+       * ospfd/ospf_main.c: ditto
+       * ripngd/ripng_main.c: ditto
+       * vtysh/vtysh_main.c: ditto
+       * ripd/rip_main.c: Change the config check option to
+       '-C' and tidy up the code.
+       * zebra/main.c: ditto   
+
+2006-10-04 Stergiakis Alexandros <astergiakis@antcor.com>
+
+       * ripd/rip_main.c: This trivial patch introduces a new
+         command-line option '-c', which instructs zebra/ripd
+         to check its configuration file for validity, print 
+         any error message, and then exit. This is useful when
+         the configuration file is edited by hand or otherwise,
+         and you simply want to validate it without any other
+         effect.
+       * zebra/main.c: ditto
+
 2006-08-27 Paul Jakma <paul.jakma@sun.com>
 
        * configure.ac: Bump to 0.99.5
index 0baae3bfdb0be224488120b751b9f5c1cda312e7..ecfe62ef1cc7fe247aa49b62bcf2dac434562427 100644 (file)
@@ -50,6 +50,7 @@ struct option longopts[] =
   { "user",        required_argument, NULL, 'u'},
   { "group",       required_argument, NULL, 'g'},
   { "version",     no_argument,       NULL, 'v'},
+  { "dryrun",      no_argument,       NULL, 'C'},
   { "help",        no_argument,       NULL, 'h'},
   { 0 }
 };
@@ -141,6 +142,7 @@ redistribution between different routing protocols.\n\n\
 -u, --user         User to run as\n\
 -g, --group        Group to run as\n\
 -v, --version      Print program version\n\
+-C, --dryrun       Check configuration for validity and exit\n\
 -h, --help         Display this help and exit\n\
 \n\
 Report bugs to %s\n", progname, ZEBRA_BUG_ADDRESS);
@@ -196,6 +198,7 @@ main (int argc, char **argv)
   char *p;
   int opt;
   int daemon_mode = 0;
+  int dryrun = 0;
   char *progname;
   struct thread thread;
 
@@ -214,7 +217,7 @@ main (int argc, char **argv)
   /* Command line argument treatment. */
   while (1) 
     {
-      opt = getopt_long (argc, argv, "df:i:hp:A:P:rnu:g:v", longopts, 0);
+      opt = getopt_long (argc, argv, "df:i:hp:A:P:rnu:g:vC", longopts, 0);
     
       if (opt == EOF)
        break;
@@ -265,6 +268,9 @@ main (int argc, char **argv)
          print_version (progname);
          exit (0);
          break;
+       case 'C':
+         dryrun = 1;
+         break;
        case 'h':
          usage (progname, 0);
          break;
@@ -294,6 +300,10 @@ main (int argc, char **argv)
   /* Parse config file. */
   vty_read_config (config_file, config_default);
 
+  /* Start execution only if not in dry-run mode */
+  if(dryrun)
+    return(0);
+  
   /* Turn into daemon if daemon_mode is set. */
   if (daemon_mode)
     daemon (0, 0);
index 6971874d4e42bb44aa54cd5eb1a0b0d02f7b985c..74fc647542914e78db69c8107cfdd294050ab282 100644 (file)
@@ -80,6 +80,7 @@ struct option longopts[] = {
   {"user", required_argument, NULL, 'u'},
   {"group", required_argument, NULL, 'g'},
   {"version", no_argument, NULL, 'v'},
+  {"dryrun", no_argument, NULL, 'C'},
   {"help", no_argument, NULL, 'h'},
   {0}
 };
@@ -124,6 +125,7 @@ Daemon which manages IS-IS routing\n\n\
 -u, --user         User to run as\n\
 -g, --group        Group to run as\n\
 -v, --version      Print program version\n\
+-C, --dryrun       Check configuration for validity and exit\n\
 -h, --help         Display this help and exit\n\
 \n\
 Report bugs to http://bugzilla.quagga.net\n", progname);
@@ -213,6 +215,7 @@ main (int argc, char **argv, char **envp)
   struct thread thread;
   char *config_file = NULL;
   char *vty_addr = NULL;
+  int dryrun = 0;
 
   /* Get the programname without the preceding path. */
   progname = ((p = strrchr (argv[0], '/')) ? ++p : argv[0]);
@@ -233,7 +236,7 @@ main (int argc, char **argv, char **envp)
   /* Command line argument treatment. */
   while (1)
     {
-      opt = getopt_long (argc, argv, "df:i:hA:p:P:u:g:v", longopts, 0);
+      opt = getopt_long (argc, argv, "df:i:hA:p:P:u:g:vC", longopts, 0);
 
       if (opt == EOF)
        break;
@@ -278,6 +281,9 @@ main (int argc, char **argv, char **envp)
          print_version ("Zebra");
          exit (0);
          break;
+       case 'C':
+         dryrun = 1;
+         break;
        case 'h':
          usage (0);
          break;
@@ -312,6 +318,10 @@ main (int argc, char **argv, char **envp)
   vty_read_config (config_file, config_default);
   vty_read_config (config_file, config_default);
 
+  /* Start execution only if not in dry-run mode */
+  if (dryrun)
+    return(0);
+  
   /* demonize */
   if (daemon_mode)
     daemon (0, 0);
index c40b46ed19c90453457ba135dd2d1db6b86432c2..8380bc89bdc3898910810d185798e311e714618f 100644 (file)
@@ -77,6 +77,7 @@ struct option longopts[] =
   { "user",        required_argument, NULL, 'u'},
   { "group",       required_argument, NULL, 'g'},
   { "version",     no_argument,       NULL, 'v'},
+  { "dryrun",      no_argument,       NULL, 'C'},
   { "help",        no_argument,       NULL, 'h'},
   { 0 }
 };
@@ -114,6 +115,7 @@ Daemon which manages OSPF version 3.\n\n\
 -u, --user         User to run as\n\
 -g, --group        Group to run as\n\
 -v, --version      Print program version\n\
+-C, --dryrun       Check configuration for validity and exit\n\
 -h, --help         Display this help and exit\n\
 \n\
 Report bugs to zebra@zebra.org\n", progname);
@@ -184,6 +186,7 @@ main (int argc, char *argv[], char *envp[])
   int vty_port = 0;
   char *config_file = NULL;
   struct thread thread;
+  int dryrun = 0;
 
   /* Set umask before anything for security */
   umask (0027);
@@ -194,7 +197,7 @@ main (int argc, char *argv[], char *envp[])
   /* Command line argument treatment. */
   while (1) 
     {
-      opt = getopt_long (argc, argv, "df:i:hp:A:P:u:g:v", longopts, 0);
+      opt = getopt_long (argc, argv, "df:i:hp:A:P:u:g:vC", longopts, 0);
     
       if (opt == EOF)
         break;
@@ -236,6 +239,9 @@ main (int argc, char *argv[], char *envp[])
           print_version (progname);
           exit (0);
           break;
+       case 'C':
+         dryrun = 1;
+         break;
         case 'h':
           usage (progname, 0);
           break;
@@ -271,6 +277,10 @@ main (int argc, char *argv[], char *envp[])
   /* parse config file */
   vty_read_config (config_file, config_default);
 
+  /* Start execution only if not in dry-run mode */
+  if (dryrun)
+    return(0);
+  
   if (daemon_mode)
     daemon (0, 0);
 
index c105f1926890c9b2f769fc4d27c6fd504c87d607..27a12dd04a18ffc9096ccb5448d3bb42b6216235 100644 (file)
@@ -81,6 +81,7 @@ struct option longopts[] =
   { "config_file", required_argument, NULL, 'f'},
   { "pid_file",    required_argument, NULL, 'i'},
   { "log_mode",    no_argument,       NULL, 'l'},
+  { "dryrun",      no_argument,       NULL, 'C'},
   { "help",        no_argument,       NULL, 'h'},
   { "vty_addr",    required_argument, NULL, 'A'},
   { "vty_port",    required_argument, NULL, 'P'},
@@ -122,6 +123,7 @@ Daemon which manages OSPF.\n\n\
 -g, --group        Group to run as\n\
 -a. --apiserver    Enable OSPF apiserver\n\
 -v, --version      Print program version\n\
+-C, --dryrun       Check configuration for validity and exit\n\
 -h, --help         Display this help and exit\n\
 \n\
 Report bugs to %s\n", progname, ZEBRA_BUG_ADDRESS);
@@ -182,6 +184,7 @@ main (int argc, char **argv)
   char *config_file = NULL;
   char *progname;
   struct thread thread;
+  int dryrun = 0;
 
   /* Set umask before anything for security */
   umask (0027);
@@ -212,7 +215,7 @@ main (int argc, char **argv)
     {
       int opt;
 
-      opt = getopt_long (argc, argv, "dlf:i:hA:P:u:g:av", longopts, 0);
+      opt = getopt_long (argc, argv, "dlf:i:hA:P:u:g:avC", longopts, 0);
     
       if (opt == EOF)
        break;
@@ -259,6 +262,9 @@ main (int argc, char **argv)
          print_version (progname);
          exit (0);
          break;
+       case 'C':
+         dryrun = 1;
+         break;
        case 'h':
          usage (progname, 0);
          break;
@@ -303,6 +309,10 @@ main (int argc, char **argv)
   /* Get configuration file. */
   vty_read_config (config_file, config_default);
 
+  /* Start execution only if not in dry-run mode */
+  if (dryrun)
+    return(0);
+  
   /* Change to the daemon program. */
   if (daemon_mode)
     daemon (0, 0);
index c9d564b7cc4426053345ea96ea3c0c3a8bc0206b..dfcd6c2666e944a8e65396d16c8bfc4e74151784 100644 (file)
@@ -42,6 +42,7 @@ static struct option longopts[] =
   { "config_file", required_argument, NULL, 'f'},
   { "pid_file",    required_argument, NULL, 'i'},
   { "help",        no_argument,       NULL, 'h'},
+  { "dryrun",      no_argument,       NULL, 'C'},
   { "vty_addr",    required_argument, NULL, 'A'},
   { "vty_port",    required_argument, NULL, 'P'},
   { "retain",      no_argument,       NULL, 'r'},
@@ -110,6 +111,7 @@ Daemon which manages RIP version 1 and 2.\n\n\
 -i, --pid_file     Set process identifier file name\n\
 -A, --vty_addr     Set vty's bind address\n\
 -P, --vty_port     Set vty's port number\n\
+-C, --dryrun       Check configuration for validity and exit\n\
 -r, --retain       When program terminates, retain added route by ripd.\n\
 -u, --user         User to run as\n\
 -g, --group        Group to run as\n\
@@ -185,6 +187,7 @@ main (int argc, char **argv)
 {
   char *p;
   int daemon_mode = 0;
+  int dryrun = 0;
   char *progname;
   struct thread thread;
 
@@ -203,7 +206,7 @@ main (int argc, char **argv)
     {
       int opt;
 
-      opt = getopt_long (argc, argv, "df:i:hA:P:u:g:rv", longopts, 0);
+      opt = getopt_long (argc, argv, "df:i:hA:P:u:g:rvC", longopts, 0);
     
       if (opt == EOF)
        break;
@@ -238,6 +241,9 @@ main (int argc, char **argv)
        case 'r':
          retain_mode = 1;
          break;
+       case 'C':
+         dryrun = 1;
+         break;
        case 'u':
          ripd_privs.user = optarg;
          break;
@@ -280,6 +286,10 @@ main (int argc, char **argv)
   /* Get configuration file. */
   vty_read_config (config_file, config_default);
 
+  /* Start execution only if not in dry-run mode */
+  if(dryrun)
+    return (0);
+  
   /* Change to the daemon program. */
   if (daemon_mode)
     daemon (0, 0);
index e6276c1be709c8c69353d7c2c9daf627f98c94cc..7055391052485f7a4674a1c9b51ff51a77291cc3 100644 (file)
@@ -48,6 +48,7 @@ struct option longopts[] =
   { "config_file", required_argument, NULL, 'f'},
   { "pid_file",    required_argument, NULL, 'i'},
   { "log_mode",    no_argument,       NULL, 'l'},
+  { "dryrun",      no_argument,       NULL, 'C'},
   { "help",        no_argument,       NULL, 'h'},
   { "vty_addr",    required_argument, NULL, 'A'},
   { "vty_port",    required_argument, NULL, 'P'},
@@ -119,6 +120,7 @@ Daemon which manages RIPng.\n\n\
 -u, --user         User to run as\n\
 -g, --group        Group to run as\n\
 -v, --version      Print program version\n\
+-C, --dryrun       Check configuration for validity and exit\n\
 -h, --help         Display this help and exit\n\
 \n\
 Report bugs to %s\n", progname, ZEBRA_BUG_ADDRESS);
@@ -190,6 +192,7 @@ main (int argc, char **argv)
   int daemon_mode = 0;
   char *progname;
   struct thread thread;
+  int dryrun = 0;
 
   /* Set umask before anything for security */
   umask (0027);
@@ -204,7 +207,7 @@ main (int argc, char **argv)
     {
       int opt;
 
-      opt = getopt_long (argc, argv, "dlf:i:hA:P:u:g:v", longopts, 0);
+      opt = getopt_long (argc, argv, "dlf:i:hA:P:u:g:vC", longopts, 0);
     
       if (opt == EOF)
        break;
@@ -252,6 +255,9 @@ main (int argc, char **argv)
          print_version (progname);
          exit (0);
          break;
+       case 'C':
+         dryrun = 1;
+         break;
        case 'h':
          usage (progname, 0);
          break;
@@ -281,6 +287,10 @@ main (int argc, char **argv)
   /* Get configuration file. */
   vty_read_config (config_file, config_default);
 
+  /* Start execution only if not in dry-run mode */
+  if(dryrun)
+    return(0);
+  
   /* Change to the daemon program. */
   if (daemon_mode)
     daemon (0, 0);
index 134bcf73ca4df451b5a6abd53f67270dd199302a..51f376c773fe72e9df981e35e877975df4faf2b0 100644 (file)
@@ -138,6 +138,7 @@ usage (int status)
            "-c, --command            Execute argument as command\n" \
            "-d, --daemon             Connect only to the specified daemon\n" \
            "-E, --echo               Echo prompt and command in -c mode\n" \
+           "-C, --dryrun             Check configuration for validity and exit\n" \
            "-h, --help               Display this help and exit\n\n" \
            "Note that multiple commands may be executed from the command\n" \
            "line by passing multiple -c args, or by embedding linefeed\n" \
@@ -156,6 +157,7 @@ struct option longopts[] =
   { "command",              required_argument,       NULL, 'c'},
   { "daemon",               required_argument,       NULL, 'd'},
   { "echo",                 no_argument,             NULL, 'E'},
+  { "dryrun",              no_argument,             NULL, 'C'},
   { "help",                 no_argument,             NULL, 'h'},
   { 0 }
 };
@@ -195,6 +197,7 @@ main (int argc, char **argv, char **env)
 {
   char *p;
   int opt;
+  int dryrun = 0;
   int boot_flag = 0;
   const char *daemon_name = NULL;
   struct cmd_rec {
@@ -210,7 +213,7 @@ main (int argc, char **argv, char **env)
   /* Option handling. */
   while (1) 
     {
-      opt = getopt_long (argc, argv, "be:c:d:Eh", longopts, 0);
+      opt = getopt_long (argc, argv, "be:c:d:EhC", longopts, 0);
     
       if (opt == EOF)
        break;
@@ -242,6 +245,9 @@ main (int argc, char **argv, char **env)
        case 'E':
          echo_command = 1;
          break;
+       case 'C':
+         dryrun = 1;
+         break;
        case 'h':
          usage (0);
          break;
@@ -270,6 +276,10 @@ main (int argc, char **argv, char **env)
   /* Read vtysh configuration file before connecting to daemons. */
   vtysh_read_config (config_default);
 
+  /* Start execution only if not in dry-run mode */
+  if(dryrun)
+    return(0);
+  
   /* Make sure we pass authentication before proceeding. */
   vtysh_auth ();
 
index dbe1b537df8c2aaeb3376867d53ae08551dbbb24..ed45bd13f7a80e73553345c8df679b62071f51ec 100644 (file)
@@ -76,6 +76,7 @@ struct option longopts[] =
   { "vty_addr",    required_argument, NULL, 'A'},
   { "vty_port",    required_argument, NULL, 'P'},
   { "retain",      no_argument,       NULL, 'r'},
+  { "dryrun",      no_argument,       NULL, 'C'},
 #ifdef HAVE_NETLINK
   { "nl-bufsize",  required_argument, NULL, 's'},
 #endif /* HAVE_NETLINK */
@@ -131,6 +132,7 @@ usage (char *progname, int status)
              "-k, --keep_kernel  Don't delete old routes which installed by "\
                                  "zebra.\n"\
              "-l, --log_mode     Set verbose log mode flag\n"\
+             "-C, --dryrun       Check configuration for validity and exit\n"\
              "-A, --vty_addr     Set vty's bind address\n"\
              "-P, --vty_port     Set vty's port number\n"\
              "-r, --retain       When program terminates, retain added route "\
@@ -208,6 +210,7 @@ main (int argc, char **argv)
   char *p;
   char *vty_addr = NULL;
   int vty_port = ZEBRA_VTY_PORT;
+  int dryrun = 0;
   int batch_mode = 0;
   int daemon_mode = 0;
   char *config_file = NULL;
@@ -228,9 +231,9 @@ main (int argc, char **argv)
       int opt;
   
 #ifdef HAVE_NETLINK  
-      opt = getopt_long (argc, argv, "bdklf:i:hA:P:ru:g:vs:", longopts, 0);
+      opt = getopt_long (argc, argv, "bdklf:i:hA:P:ru:g:vs:C", longopts, 0);
 #else
-      opt = getopt_long (argc, argv, "bdklf:i:hA:P:ru:g:v", longopts, 0);
+      opt = getopt_long (argc, argv, "bdklf:i:hA:P:ru:g:vC", longopts, 0);
 #endif /* HAVE_NETLINK */
 
       if (opt == EOF)
@@ -248,6 +251,9 @@ main (int argc, char **argv)
        case 'k':
          keep_kernel_mode = 1;
          break;
+       case 'C':
+         dryrun = 1;
+         break;
        case 'l':
          /* log_mode = 1; */
          break;
@@ -345,6 +351,10 @@ main (int argc, char **argv)
   /* Configuration file read*/
   vty_read_config (config_file, config_default);
 
+  /* Don't start execution if we are in dry-run mode */
+  if (dryrun)
+    return(0);
+  
   /* Clean up rib. */
   rib_weed_tables ();