aboutsummaryrefslogtreecommitdiffstats
path: root/add-syslog
diff options
context:
space:
mode:
authorGuillaume Rousse <guillomovitch@mandriva.org>2007-09-06 12:02:06 +0000
committerGuillaume Rousse <guillomovitch@mandriva.org>2007-09-06 12:02:06 +0000
commit69209c47ff4b5ec74c3ba13ff54d28e2a6cf3ca2 (patch)
tree492d906aac62cffa3f11842d90fee8fb0917201e /add-syslog
parentae092ecc77122af86b4525df11fe2e8a89a6aa24 (diff)
downloadrpm-helper-69209c47ff4b5ec74c3ba13ff54d28e2a6cf3ca2.tar
rpm-helper-69209c47ff4b5ec74c3ba13ff54d28e2a6cf3ca2.tar.gz
rpm-helper-69209c47ff4b5ec74c3ba13ff54d28e2a6cf3ca2.tar.bz2
rpm-helper-69209c47ff4b5ec74c3ba13ff54d28e2a6cf3ca2.tar.xz
rpm-helper-69209c47ff4b5ec74c3ba13ff54d28e2a6cf3ca2.zip
switch to short options (rpm macros can't handle long ones), and fix a few issues
Diffstat (limited to 'add-syslog')
-rwxr-xr-xadd-syslog31
1 files changed, 14 insertions, 17 deletions
diff --git a/add-syslog b/add-syslog
index a268658..c2fa775 100755
--- a/add-syslog
+++ b/add-syslog
@@ -1,27 +1,25 @@
#!/usr/bin/perl
# rpm helper scriptlet to add a syslog entry (sysklogd and syslog-ng)
# $Id$
-use Getopt::Long;
+use Getopt::Std;
use strict;
-my $source = '/dev/log';
-my $facility = '';
-my $min = 'debug';
-my $max = 'emerg';
-GetOptions(
- "source=s" => \$source,
- "facility=s" => \$facility,
- "min=s" => \$min,
- "max=s" => \$max,
+my %opts = (
+ s => '/dev/log',
+ f => undef,
+ m => 'debug',
+ M => 'emerg'
);
+getopts('s:f:m:M:', \%opts);
+my ($source, $facility, $min, $max) = @opts{qw/s f m M/};
die <<EOF if @ARGV < 3;
usage: $0 [options] <pkg> <nb> <dest>
Available options:
---source <source> (default: /dev/log)
---facility <facility> (default: first local available)
---min <priority> (default: debug)
---max <priority> (default: emerg)
+-s <source> source (default: /dev/log)
+-f <facility> facility (default: first local available)
+-m <priority> min priority (default: debug)
+-M <priority> max priority (default: emerg)
EOF
my ($package, $number, $dest) = @ARGV;
@@ -81,7 +79,7 @@ add_syslogng_facility($package, $source, $dest, $facility, $min, $max)
if -f '/etc/syslog-ng.conf';
# output used facility as feedback
-print $facility
+print $facility;
sub add_sysklogd_facility {
my ($package, $source, $dest, $facility, $min, $max) = @_;
@@ -132,7 +130,7 @@ sub add_sysklogd_facility {
# compute spacing to keep default configuration file formatting
my $tabs = length($selector) < 48 ?
- (((48 - length($selector)) / 8) + 1) :
+ ((48 - length($selector)) / 8) :
1;
# append entry
@@ -200,7 +198,6 @@ sub add_syslogng_facility {
last FILTER if !$line;
}
}
- print $line;
}
close($fh);