blob: e344a44245e6468235cced7c09066d2aa2155d97 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#!/usr/bin/perl
# rpm helper scriptlet to remove a syslog entry (sysklogd and syslog-ng)
# $Id$
die <<EOF if @ARGV < 2;
usage: $0 <pkg> <nb>
EOF
if (-f '/etc/syslog.conf') {
del_syslog_entry($package, '/etc/syslog.conf');
system(qw/service syslog condrestart/);
}
if (-f '/etc/syslog-ng.conf') {
del_syslog_entry($package, '/etc/syslog-ng.conf');
system(qw/service syslog-ng condrestart/);
}
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);
}
|