aboutsummaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2009-08-05 08:17:53 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2009-08-05 08:17:53 +0000
commit74294c061a5ecfa0986ac7684de197987d435bea (patch)
treed8a849084197503a7d9dd52eb3be2d7c670f2f20 /main
parent11760a8485da27422f78ee8212d5413ec93ff0f3 (diff)
downloadaports-74294c061a5ecfa0986ac7684de197987d435bea.tar.bz2
aports-74294c061a5ecfa0986ac7684de197987d435bea.tar.xz
main/sysklogd: use cron to rotate logs rather than logrotate
The cronscript parses the syslog.conf and dynamically rotates all configured log files, while logrotate is a static list. This way we avoid needing to update the logrotate script each time you change syslog.conf
Diffstat (limited to 'main')
-rw-r--r--main/sysklogd/APKBUILD12
-rwxr-xr-xmain/sysklogd/sysklogd.daily82
-rw-r--r--main/sysklogd/sysklogd.logrotate12
-rw-r--r--main/sysklogd/syslog.conf6
4 files changed, 99 insertions, 13 deletions
diff --git a/main/sysklogd/APKBUILD b/main/sysklogd/APKBUILD
index 43ce5aa54..ea561d1f6 100644
--- a/main/sysklogd/APKBUILD
+++ b/main/sysklogd/APKBUILD
@@ -1,15 +1,16 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=sysklogd
pkgver=1.5
-pkgrel=1
+pkgrel=2
pkgdesc="System and kernel log daemons"
url="http://www.infodrom.org/projects/sysklogd/"
license="GPL BSD"
subpackages="$pkgname-doc"
-depends="logrotate"
+depends=
makedepends=""
source="http://www.infodrom.org/projects/$pkgname/download/$pkgname-$pkgver.tar.gz
sysklogd.logrotate
+ sysklogd.daily
sysklogd.initd
sysklogd.confd
sysklogd-1.4.2-caen-owl-klogd-drop-root.diff
@@ -37,13 +38,16 @@ build ()
make INSTALL=install prefix="$pkgdir" install
install -D -m644 ../sysklogd.logrotate \
"$pkgdir"/etc/logrotate.d/sysklogd
+ install -D -m755 ../sysklogd.daily \
+ "$pkgdir"/etc/periodic/daily/sysklogd
install -D -m755 ../sysklogd.initd "$pkgdir"/etc/init.d/sysklogd
install -D -m644 ../sysklogd.confd "$pkgdir"/etc/conf.d/sysklogd
install -D -m644 ../syslog.conf "$pkgdir"/etc/syslog.conf
install -D -m644 ../LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}
md5sums="e053094e8103165f98ddafe828f6ae4b sysklogd-1.5.tar.gz
-40304e92b2f6a92e252de24c5e3ca88e sysklogd.logrotate
+6bc1d1c65076b104a8f78d0fb4f21db7 sysklogd.logrotate
+c9274a06835b95feb8aab31523418847 sysklogd.daily
9332657663a9f4286e5c61d22c46378f sysklogd.initd
e25d7b583b7e4bd8be503b89e1771e90 sysklogd.confd
3b7ba3aa6519f96f11165a7d5900a8b1 sysklogd-1.4.2-caen-owl-klogd-drop-root.diff
@@ -51,5 +55,5 @@ e25d7b583b7e4bd8be503b89e1771e90 sysklogd.confd
6c0a416e40a678cf99c454b0e98185c9 sysklogd-1.4.2-caen-owl-syslogd-drop-root.diff
c71826d1a4f3f7e8ffa57adbfc24f1ce sysklogd-1.5-build.patch
8e70cdf98cce9defae0c28a3d2db4410 ksym-fclose-fix.diff
-49ba209742f1651f4bda6c5e92cbb3eb syslog.conf
+16019757e6af519be8cf3398b97e0f1b syslog.conf
7930f7ff5038e1318511624e348581cc LICENSE"
diff --git a/main/sysklogd/sysklogd.daily b/main/sysklogd/sysklogd.daily
new file mode 100755
index 000000000..79e85fb46
--- /dev/null
+++ b/main/sysklogd/sysklogd.daily
@@ -0,0 +1,82 @@
+#!/bin/sh
+# This is a shell script replacement for the sysklogd's logrotate cron script
+# and syslogd-listfiles perl script.
+# Copyright (C) 2008 N. Angelacos for the Alpine Linux project - GPL2
+
+
+CONF="/etc/syslog.conf"
+
+
+syslogd_listfiles() {
+ # List the target files from syslog.conf
+
+ local skip="auth"
+ [ "$1" = "--auth" ] && skip=" "
+
+ # the while loop joins lines that end in "\"
+ # the sed (in order)-
+ # strips comments;
+ # collapses spaces/tabs to 1 space;
+ # deletes the "-" in front of the filename;
+ # deletes lines that have the "skip" facility
+ # deletes the facility (leaving just the filename)
+ # deletes lines that are not filenames with leading "/"
+ while read a ; do echo "$a"; done < $CONF |\
+ sed -n "/^ *#/D; /^[ ]*$/D; s/[ ]\+/ /g; \
+ s+ -/+ /+g; /^.*\($skip\)[^ ]* /D; \
+ s/^[^ ]* //; /^[^\\/]/D; P" |\
+ sort | uniq
+}
+
+# dumb little savelog - no error checking here
+savelog () {
+ local group="adm"
+ local mode="644"
+ local user="root"
+ local cycle=2
+ local logfile=""
+
+ # parse args
+ while getopts "g:u:m:c:" opt; do
+ case $opt in
+ g) group=$OPTARG ;;
+ u) user=$OPTARG ;;
+ m) mode=$OPTARG ;;
+ c) cycle=$OPTARG ;;
+ *) echo "unknown option: $opt" >&2 && return 1;;
+ esac
+ done
+ shift $(( $OPTIND - 1 ))
+ logfile=$1
+
+ # Cycle the logs
+ while [ $cycle -ne 0 ]; do
+ p=$cycle
+ cycle=$(( $cycle - 1 ))
+ a=$logfile.$cycle*
+ b=$( echo $a | sed "s/\.$cycle/\.$p/")
+ [ -f $a ] && mv $a $b
+ done
+
+ # compress .1 and let .0 be uncompressed
+ [ -f $logfile.1 ] && gzip $logfile.1
+ [ -f $logfile ] && mv $logfile $logfile.0
+
+ # set permissions
+ chown $user:$group $logfile.* 2>/dev/null
+ chmod $mode $logfile.* 2>/dev/null
+}
+
+
+# Main script
+
+for LOG in $( syslogd_listfiles ); do
+ [ -f $LOG ] && savelog -g adm -m 640 -u root -c 7 $LOG
+done
+
+for LOG in $(syslogd_listfiles --auth); do
+ [ -f $LOG ] && savelog -g adm -m 640 -u root -c 7 $LOG
+done
+
+killall -HUP syslogd
+
diff --git a/main/sysklogd/sysklogd.logrotate b/main/sysklogd/sysklogd.logrotate
index 29afd15bd..0fd0be2ff 100644
--- a/main/sysklogd/sysklogd.logrotate
+++ b/main/sysklogd/sysklogd.logrotate
@@ -1,6 +1,6 @@
-/var/log/messages /var/log/auth /var/log/mail /var/log/errors /var/log/kernel {
- sharedscripts
- postrotate
- /etc/init.d/sysklogd --quiet reload
- endscript
-}
+# we do logrotatation in a separate cron script that parses syslog.conf
+# and rotates whatever user have configured.
+#
+# That is better than having users to maunally update this logrotate config
+# whenever they touch syslog.conf
+#
diff --git a/main/sysklogd/syslog.conf b/main/sysklogd/syslog.conf
index 855ee6e3e..aead955cc 100644
--- a/main/sysklogd/syslog.conf
+++ b/main/sysklogd/syslog.conf
@@ -18,9 +18,9 @@ user.* -/var/log/user.log
# Logging for the mail system. Split it up so that
# it is easy to write scripts to parse these files.
#
-mail.info -/var/log/mail.info
-mail.warning -/var/log/mail.warn
-mail.err /var/log/mail.err
+#mail.info -/var/log/mail.info
+#mail.warning -/var/log/mail.warn
+#mail.err /var/log/mail.err
# Some `catch-all' logfiles.
#