#!/usr/bin/perl # rpm helper scriptlet to remove a syslog entry (sysklogd and syslog-ng) # $Id$ die < EOF foreach my $file ('/etc/syslog.conf', '/etc/syslog-ng.conf') { del_syslog_entry($package, $file) if -f $file; } sub del_syslog_entry { my ($package, $file) = @_; my $content; open(my $in, '<', $file) or die "Can't open $file for reading: $!"; while (my $line = <$in>) { if ($line =~ /^# BEGIN: Automatically added by $package installation$/) { while ($line = <$in>) { last if $line =~ /^# END$/; } } else { $content .= $line; } } open(my $out, '>', $file) or die "Can't open $file for writing: $!"; print $out $content; close($out); }