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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
#!/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
# Update init script priorities
if dpkg --compare-versions "$2" lt "3.20.2-1"; then
for i in 0 6 ; do
if [ -e /etc/rc$i.d/K90rsyslog ]; then
mv /etc/rc$i.d/K90rsyslog /etc/rc$i.d/S30rsyslog
fi
done
fi
local user_conf=/etc/rsyslog.d/50-default.conf
local default_conf=/usr/share/rsyslog/50-default.conf
# Upgrade handling for config file. We copy syslog.conf if it exists and
# is modified, else use our default fresh-install config.
if dpkg --compare-versions "$2" lt "3.22.0-1ubuntu1"; then
local pkg_name=sysklogd
local old_conf=/etc/syslog.conf
if [ -e $old_conf ]; then
local md5sum="`md5sum \"$old_conf\" | sed -e \"s/ .*//\"`"
local old_md5sum="$(dpkg-query -W -f='${Conffiles}' $pkg_name | \
sed -n -e "\' $old_conf ' { s/ obsolete$//; s/.* //; p }")"
if [ "$md5sum" != "$old_md5sum" ]; then
cp -n $old_conf $user_conf
fi
fi
fi
ucf --three-way --debconf-ok $default_conf $user_conf
ucfr rsyslog $user_conf
adduser --system --group --no-create-home --quiet syslog || true
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
#DEBHELPER#
exit 0
|