summaryrefslogtreecommitdiff
path: root/scripts/system/vyatta_update_logrotate.pl
diff options
context:
space:
mode:
authorAn-Cheng Huang <ancheng@vyatta.com>2007-09-25 15:55:26 -0700
committerAn-Cheng Huang <ancheng@vyatta.com>2007-09-25 15:55:26 -0700
commite9a79a249cec69fc178098d2f75db9389068510a (patch)
tree0e366094b7fecd3988c243fbbb574015e0c900c8 /scripts/system/vyatta_update_logrotate.pl
downloadvyatta-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_logrotate.pl')
-rw-r--r--scripts/system/vyatta_update_logrotate.pl55
1 files changed, 55 insertions, 0 deletions
diff --git a/scripts/system/vyatta_update_logrotate.pl b/scripts/system/vyatta_update_logrotate.pl
new file mode 100644
index 0000000..2740526
--- /dev/null
+++ b/scripts/system/vyatta_update_logrotate.pl
@@ -0,0 +1,55 @@
+#!/usr/bin/perl
+
+use strict;
+
+my $file = "messages";
+my $log_file = "/var/log/messages";
+if ($#ARGV == 3) {
+ $file = shift;
+ $log_file = "/var/log/user/$file";
+}
+my $files = shift;
+my $size = shift;
+my $set = shift;
+my $log_conf = "/etc/logrotate.d/$file";
+
+if (!defined($files) || !defined($size) || !defined($set)) {
+ exit 1;
+}
+
+if (!($files =~ m/^\d+$/) || !($size =~ m/^\d+$/)) {
+ exit 2;
+}
+
+# just remove it and make a new one below
+# (the detection mechanism in XORP doesn't work anyway)
+unlink $log_conf;
+
+open(OUT, ">>$log_conf") or exit 3;
+if ($set == 1) {
+ print OUT <<EOF;
+$log_file {
+ missingok
+ notifempty
+ rotate $files
+ size=${size}k
+ postrotate
+ kill -HUP `cat /var/run/syslogd.pid`
+ endscript
+}
+EOF
+}
+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 4;
+}
+
+exit 0;
+