diff options
author | An-Cheng Huang <ancheng@sydney.vyatta.com> | 2007-10-19 11:26:15 -0700 |
---|---|---|
committer | An-Cheng Huang <ancheng@sydney.vyatta.com> | 2007-10-19 11:26:15 -0700 |
commit | 07183520f3f4d2f89e526055db418046d0d2450f (patch) | |
tree | 7968eac48a0a57ff97ec4769d999bf31348a2a12 /scripts/system/vyatta_update_syslog.pl | |
parent | 66b621cf7759c3448ae8bfe7d7479fb13ea04b65 (diff) | |
download | vyatta-cfg-quagga-07183520f3f4d2f89e526055db418046d0d2450f.tar.gz vyatta-cfg-quagga-07183520f3f4d2f89e526055db418046d0d2450f.zip |
move "system" configuration templates/scripts from vyatta-cfg.
Diffstat (limited to 'scripts/system/vyatta_update_syslog.pl')
-rwxr-xr-x | scripts/system/vyatta_update_syslog.pl | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/scripts/system/vyatta_update_syslog.pl b/scripts/system/vyatta_update_syslog.pl new file mode 100755 index 00000000..a55fe615 --- /dev/null +++ b/scripts/system/vyatta_update_syslog.pl @@ -0,0 +1,51 @@ +#!/usr/bin/perl + +use strict; +my $SYSLOG_CONF = '/etc/syslog.conf'; + +my $match1 = shift; +my $match2 = shift; +my $update_line = shift; + +if (!defined($match1) || !defined($match2) || !defined($update_line)) { + exit 1; +} + +if (system("touch $SYSLOG_CONF")) { + exit 2; +} + +my $exp1 = ""; +my $exp2 = ""; +if ($match1 ne "") { + $exp1 = $match1; + if ($match2 ne "") { + $exp2 = $match2; + } +} elsif ($match2 ne "") { + $exp1 = $match2; +} + +if ($exp2 ne "") { + if (system("sed -i '/$exp1/{/$exp2/d}' $SYSLOG_CONF")) { + exit 2; + } +} elsif ($exp1 ne "") { + if (system("sed -i '/$exp1/d' $SYSLOG_CONF")) { + exit 3; + } +} + +open(OUT, ">>$SYSLOG_CONF") or exit 4; +if ($update_line ne "") { + print OUT "$update_line"; +} +close OUT; + +sleep 1; +if (system("/usr/sbin/invoke-rc.d sysklogd restart")) { + exit 5; +} + +exit 0; + |