blob: ed856d932b9a6fb6ee8f3c4b2b72972737964845 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
#!/bin/sh
set -e
# summary of how this script can be called:
# * <postinst> `configure' <most-recently-configured-version>
# * <old-postinst> `abort-upgrade' <new version>
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
# <new-version>
# * <postinst> `abort-remove'
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
# <failed-install-package> <version> `removing'
# <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package
rotate_old_log_files()
{
log_files="syslog mail.info mail.warn mail.err mail.log daemon.log \
kern.log auth.log user.log lpr.log cron.log debug messages"
skipped_files=""
dir=/var/log
for f in $log_files; do
if [ -e $dir/$f.0 ]; then
rotate="yes"
if [ -e $dir/$f.1.gz ]; then
date0=$(stat --format=%Y $dir/$f.0)
date1=$(stat --format=%Y $dir/$f.1.gz)
if [ $date0 -lt $date1 ] ; then
# .0 log file is older than .1
skipped_files="$dir/$f.0\n$skipped_files"
rotate="no"
fi
fi
if [ "$rotate" = "yes" ] ; then
for s in $(seq 9 -1 1) ; do
if [ -e $dir/$f.$s.gz ]; then
mv $dir/$f.$s.gz $dir/$f.$(($s+1)).gz
fi
done
mv $dir/$f.0 $dir/$f.1
fi
fi
done
if [ -n "$skipped_files" ]; then
printf "The following old log files were found which could not be rotated safely.\n"
printf "\n$skipped_files\n"
printf "Please inspect them manually and delete them, if no longer required.\n"
fi
}
case "$1" in
configure)
# Rotate .0 log files when migrating from sysklogd
if dpkg --compare-versions "$2" lt "3.18.5-1"; then
rotate_old_log_files
fi
# Stop the service on upgrades before it is started again.
# dh_installinit -r will create the start code.
if [ -n "$2" ]; then
if [ -x "/etc/init.d/rsyslog" ]; then
invoke-rc.d rsyslog stop || true
fi
fi
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
#DEBHELPER#
exit 0
|