diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2010-11-19 15:54:51 -0800 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2010-11-19 15:54:51 -0800 |
commit | 63b242cbb560940af9c5ca492e0278811e63b4dc (patch) | |
tree | 29023672ee23bbd58af7363f0c2c10beea6e4646 /scripts/vyatta-config-loader.pl | |
parent | 40fe9012a56a7cfdfa374108fa249d2a569112b8 (diff) | |
download | vyatta-cfg-63b242cbb560940af9c5ca492e0278811e63b4dc.tar.gz vyatta-cfg-63b242cbb560940af9c5ca492e0278811e63b4dc.zip |
Display serious errors to console and syslog
Put regular stuff to /tmp/vyatta-config.log on standard output
Keep console open as standard error for messages like "commit failed"
Put errors in syslog as well
Diffstat (limited to 'scripts/vyatta-config-loader.pl')
-rwxr-xr-x | scripts/vyatta-config-loader.pl | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/scripts/vyatta-config-loader.pl b/scripts/vyatta-config-loader.pl index b07c08b..3213fcb 100755 --- a/scripts/vyatta-config-loader.pl +++ b/scripts/vyatta-config-loader.pl @@ -38,8 +38,6 @@ umask 0002; openlog("config-loader", "nofail", LOG_LOCAL0); open (STDOUT, '>>', $CONFIG_LOG) or die "Can not open $CONFIG_LOG : $!"; -open (STDERR, '>&STDOUT') - or die "Can not dup STDOUT"; # get a list of all config statement in the startup config file my %cfg_hier = Vyatta::ConfigLoad::getStartupConfigStatements($ARGV[0],'true'); @@ -54,6 +52,7 @@ unless (system("$CWRAPPER begin") == 0) { die "Cannot set up configuration environment"; } +my $fail = 0; #cmd below is added to debug last set of command ordering foreach (@all_nodes) { my ($path_ref, $rank) = @$_; @@ -91,12 +90,16 @@ foreach (@all_nodes) { $cmd = "$CWRAPPER set " . $cmd; unless (system($cmd) == 0) { $cmd =~ s/^.*?set /set /; + printf "[[%s] failed: %d\n", $cmd, $?; syslog(LOG_NOTICE, "[[%s]] failed", $cmd); - warn "[[$cmd]] failed\n"; + ++$fail; } } +warn "$fail failures (see $CONFIG_LOG)\n" if ($fail > 0); + unless (system($COMMIT_CMD) == 0) { + printf "commit failed: %d\n", $?; syslog (LOG_NOTICE, "Commit failed at boot"); warn "Commit failed at boot\n"; system($CLEANUP_CMD); @@ -106,13 +109,17 @@ unless (system($COMMIT_CMD) == 0) { # Now process any deactivate nodes my @deactivate_nodes = @{ $cfg_hier{'deactivate'} }; if (@deactivate_nodes) { + $fail = 0; + my $cmd = "$CWRAPPER deactivate " . $_; unless (system($cmd) == 0) { + printf "[[%s] failed: %d\n", $cmd, $?; syslog(LOG_NOTICE, "[[%s]] failed", $cmd); - warn "[[$cmd]] failed\n"; } + warn "$fail deactivate failures (see $CONFIG_LOG)\n" if ($fail > 0); unless (system($COMMIT_CMD) == 0) { + printf "deactivate commit failed: %d\n", $?; syslog(LOG_NOTICE, "Commit deactivate failed at boot"); warn "Commit deactivate failed at boot\n"; system($CLEANUP_CMD); @@ -120,7 +127,6 @@ if (@deactivate_nodes) { } # really clean up -exec "$CWRAPPER end"; - -die "exec of $CWRAPPER failed"; +exec "$CWRAPPER end" + or die "exec of $CWRAPPER failed"; |