summaryrefslogtreecommitdiff
path: root/scripts/system/vyatta_update_logrotate.pl
diff options
context:
space:
mode:
authorAn-Cheng Huang <ancheng@sydney.vyatta.com>2007-10-19 11:26:15 -0700
committerAn-Cheng Huang <ancheng@sydney.vyatta.com>2007-10-19 11:26:15 -0700
commit07183520f3f4d2f89e526055db418046d0d2450f (patch)
tree7968eac48a0a57ff97ec4769d999bf31348a2a12 /scripts/system/vyatta_update_logrotate.pl
parent66b621cf7759c3448ae8bfe7d7479fb13ea04b65 (diff)
downloadvyatta-cfg-quagga-07183520f3f4d2f89e526055db418046d0d2450f.tar.gz
vyatta-cfg-quagga-07183520f3f4d2f89e526055db418046d0d2450f.zip
move "system" configuration templates/scripts from vyatta-cfg.
Diffstat (limited to 'scripts/system/vyatta_update_logrotate.pl')
-rwxr-xr-xscripts/system/vyatta_update_logrotate.pl50
1 files changed, 50 insertions, 0 deletions
diff --git a/scripts/system/vyatta_update_logrotate.pl b/scripts/system/vyatta_update_logrotate.pl
new file mode 100755
index 00000000..abc4a25a
--- /dev/null
+++ b/scripts/system/vyatta_update_logrotate.pl
@@ -0,0 +1,50 @@
+#!/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;
+if (system("/usr/sbin/invoke-rc.d sysklogd restart")) {
+ exit 4;
+}
+
+exit 0;
+