From 8c76eecf50f943b0a7e759f398f6d16dac53dac0 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Fri, 8 Oct 2010 17:11:30 -0700 Subject: Convert from syslog to rsyslog Configuration file is /etc/rsyslog.conf and it is supports directory of include parameters so do not need to edit rsyslog.conf directly --- scripts/system/vyatta_update_syslog.pl | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) (limited to 'scripts/system/vyatta_update_syslog.pl') diff --git a/scripts/system/vyatta_update_syslog.pl b/scripts/system/vyatta_update_syslog.pl index 8047999d..1c4c6d46 100755 --- a/scripts/system/vyatta_update_syslog.pl +++ b/scripts/system/vyatta_update_syslog.pl @@ -16,7 +16,7 @@ # # **** End License **** -# Update /etc/syslog.conf +# Update /etc/rsyslog.d/vyatta-log.conf # Exit code: 0 - update # 1 - no change or error @@ -25,12 +25,10 @@ use lib "/opt/vyatta/share/perl5"; use Vyatta::Config; use File::Compare; -my $SYSLOG_CONF = '/etc/syslog.conf'; -my $SYSLOG_TMP = "/tmp/syslog.conf.$$"; +my $SYSLOG_CONF = '/etc/rsyslog.d/vyatta-log.conf'; +my $SYSLOG_TMP = "/tmp/rsyslog.conf.$$"; my $MESSAGES = '-/var/log/messages'; my $CONSOLE = '/dev/console'; -my $BEGIN_VYATTA = '### BEGIN VYATTA'; -my $END_VYATTA = '### END VYATTA'; my %entries = (); @@ -88,26 +86,17 @@ foreach my $user ( $config->listNodes('user') ) { read_config( $config, 'user $user', $user ); } -if ( -r $SYSLOG_CONF ) { - system("sed -e '/$BEGIN_VYATTA/,/$END_VYATTA/d' <$SYSLOG_CONF >$SYSLOG_TMP") - == 0 - or die "Can't read $SYSLOG_CONF"; -} - -open my $out, '>>', $SYSLOG_TMP +open my $out, '>', $SYSLOG_TMP or die "Can't open $SYSLOG_TMP: $!"; -print $out "$BEGIN_VYATTA\n"; - foreach my $target ( keys %entries ) { print $out join( ';', @{ $entries{$target} } ), "\t$target\n"; } -print $out "$END_VYATTA\n"; close $out or die "Can't output $SYSLOG_TMP: $!"; # Don't need to do anything, save time on boot -if ( compare( $SYSLOG_CONF, $SYSLOG_TMP ) == 0 ) { +if ( -e $SYSLOG_CONF && compare( $SYSLOG_CONF, $SYSLOG_TMP ) == 0 ) { unlink($SYSLOG_TMP); exit 1; } -- cgit v1.2.3