summaryrefslogtreecommitdiffstats
path: root/ospfd/ospf_main.c
diff options
context:
space:
mode:
authorPaul Jakma <paul.jakma@sun.com>2006-10-16 01:35:57 +0200
committerPaul Jakma <paul.jakma@sun.com>2006-10-16 01:35:57 +0200
commit876b8be0ab24721e8f94d47dde022563f76db992 (patch)
tree60afcf14974d39a081b64c71191038701e73a3f5 /ospfd/ospf_main.c
parent[lib] Handle upgrade from SUNWzebra to Quagga for 'interface fooX:Y' commands (diff)
downloadfrr-876b8be0ab24721e8f94d47dde022563f76db992.tar.xz
frr-876b8be0ab24721e8f94d47dde022563f76db992.zip
[daemon startup] Add --dry-run/-C argument to daemons, to check config file syntax
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
Diffstat (limited to 'ospfd/ospf_main.c')
-rw-r--r--ospfd/ospf_main.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/ospfd/ospf_main.c b/ospfd/ospf_main.c
index c105f1926..27a12dd04 100644
--- a/ospfd/ospf_main.c
+++ b/ospfd/ospf_main.c
@@ -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);