diff options
author | An-Cheng Huang <ancheng@vyatta.com> | 2007-09-25 15:55:26 -0700 |
---|---|---|
committer | An-Cheng Huang <ancheng@vyatta.com> | 2007-09-25 15:55:26 -0700 |
commit | e9a79a249cec69fc178098d2f75db9389068510a (patch) | |
tree | 0e366094b7fecd3988c243fbbb574015e0c900c8 /scripts/system/vyatta_update_syslog.pl | |
download | vyatta-cfg-e9a79a249cec69fc178098d2f75db9389068510a.tar.gz vyatta-cfg-e9a79a249cec69fc178098d2f75db9389068510a.zip |
initial import (from eureka /cli) plus new build system.upstream
Diffstat (limited to 'scripts/system/vyatta_update_syslog.pl')
-rw-r--r-- | scripts/system/vyatta_update_syslog.pl | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/scripts/system/vyatta_update_syslog.pl b/scripts/system/vyatta_update_syslog.pl new file mode 100644 index 0000000..315e2a9 --- /dev/null +++ b/scripts/system/vyatta_update_syslog.pl @@ -0,0 +1,56 @@ +#!/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; +# XXX somehow starting syslogd with 'start-stop-daemon --start...' here fails +# with SEGV (?). just start syslogd directly. +#if (system("/opt/vyatta/sbin/sysklogd.init restart")) { +system("/opt/vyatta/sbin/sysklogd.init stop"); +sleep 1; +if (system(". /etc/default/syslogd ; /sbin/syslogd \$SYSLOGD")) { + exit 5; +} + +exit 0; + |