diff options
author | Bjoern Buerger <b.buerger@pengutronix.de> | 2006-01-25 10:33:31 +0000 |
---|---|---|
committer | Bjoern Buerger <b.buerger@pengutronix.de> | 2006-01-25 10:33:31 +0000 |
commit | 3800c192374dfa79350d83bc5166d27534c28a44 (patch) | |
tree | de97c01a70c1ef463abf05b039e0f9d88af302b6 | |
parent | 943a583a72ce6c022d0c48d4d0873b13603731c9 (diff) | |
download | ptxdist-3800c192374dfa79350d83bc5166d27534c28a44.tar.gz ptxdist-3800c192374dfa79350d83bc5166d27534c28a44.tar.xz |
added minimal logrotate
git-svn-id: https://svn.pengutronix.de/svn/ptxdist/trunks/ptxdist-0.9-trunk@4414 33e552b5-05e3-0310-8538-816dae2090ed
-rwxr-xr-x | projects/generic/etc/init.d/logrotate | 54 | ||||
-rw-r--r-- | rules/rootfs.in | 8 | ||||
-rw-r--r-- | rules/rootfs.make | 4 |
3 files changed, 66 insertions, 0 deletions
diff --git a/projects/generic/etc/init.d/logrotate b/projects/generic/etc/init.d/logrotate new file mode 100755 index 000000000..eccb24e9b --- /dev/null +++ b/projects/generic/etc/init.d/logrotate @@ -0,0 +1,54 @@ +#!/bin/sh + +# +# /etc/init.d/logrotate - Minimal Log Rotator for /var/log/*.{log,err} +# + +PREFIX="logrotate: " +LOGDIR="/var/log/" +MAXFILES="8" +PATTERNS="*.err *.log" + +my_exit(){ +echo "${PREFIX}${1}" +exit $2 +} + +logrotate(){ + cd $LOGDIR + # Rotate Backups for *.log and *.err.files + for filename in $PATTERNS; do + echo "${PREFIX}rotation for $filename ... " + for i in `seq $MAXFILES -1 1` ; do + if [ -e "$filename.$i" ] + then + f=$i; let f++ + mv -f $filename.$i $filename.$f + fi + done + [ -e "$filename" ] && mv -f $filename $filename.1 + done +} + +# +# Main +# + +[ -d "$LOGDIR" ] || my_exit "Logdir $LOGDIR missing" 1 + +case $1 in + + start) + echo "${PREFIX}Starting subsystem" + logrotate + ;; + stop) + echo "${PREFIX}Stopping subsystem" + logrotate + ;; + *) + echo "Usage: $0 [start|stop]" + ;; +esac + + diff --git a/rules/rootfs.in b/rules/rootfs.in index f2702e09e..263cdaaaa 100644 --- a/rules/rootfs.in +++ b/rules/rootfs.in @@ -357,6 +357,14 @@ config ROOTFS_ETC_INITD_RCS Its main purpose is to run the other init scripts by calling run-parts. +config ROOTFS_ETC_INITD_LOGROTATE + bool + prompt "minimal logrotate" + depends on ROOTFS_ETC_INITD + default n + help + The /etc/init.d/logrotate script is a minimal logrotator. + menuconfig ROOTFS_ETC_INITD_NETWORKING depends on ROOTFS_ETC_INITD bool diff --git a/rules/rootfs.make b/rules/rootfs.make index 689a01562..8b371e840 100644 --- a/rules/rootfs.make +++ b/rules/rootfs.make @@ -253,6 +253,10 @@ ifdef PTXCONF_ROOTFS_ETC_INITD @$(call install_copy, 0, 0, 0755, /etc/init.d) @$(call install_copy, 0, 0, 0755, $(PTXDIST_TOPDIR)/projects/generic/etc/init.d/rcS, /etc/init.d/rcS, n) +ifdef ROOTFS_ETC_INITD_LOGROTATE + @$(call install_copy, 0, 0, 0755, $(PTXDIST_TOPDIR)/projects/generic/etc/init.d/logrotate, /etc/init.d/logrotate, n) +endif + ifdef PTXCONF_ROOTFS_ETC_INITD_NETWORKING @$(call install_copy, 0, 0, 0755, $(PTXDIST_TOPDIR)/projects/generic/etc/init.d/networking, /etc/init.d/networking, n) @$(call install_copy, 0, 0, 0755, /etc/network/if-down.d) |