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
|
#!/bin/sh
# Copyright (C) 2017 Dmitry Bogatov <KAction@gnu.org>
# Author: Dmitry Bogatov <KAction@gnu.org>
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set -e
postrm () {
# Following code makes sure, that after removal of package, in default
# setup, the only files belonged to log user, belong to root.
#
# This way user can be safely removed, solving part of #848239 (need
# interoperation from dh-sysuser).
#
# Sure, system administrator can make stupid thing and chown some file
# to log user, but consequences do not seem to be so severe. After
# all, with great power comes great responsibility.
if [ -d "/var/log/runit/$NAME" ] ; then
chown --recursive root:root "/var/log/runit/$NAME"
fi
if [ "$1" != 'purge' ] ; then
return
fi
# If runscript was never invoked, there will be no files
# in this directory, and `dpkg' will remove it. In this case,
# we have nothing to do.
for supervise in "/var/lib/runit/supervise/$NAME" \
"/var/lib/runit/log/supervise/$NAME" ; do
if [ -d "$supervise" ] ; then
# Actually only `down' may be absent, but it does not
# matter.
for file in control lock ok pid stat status down ; do
rm -f "$supervise/$file"
done
# It should be empty now. If it is not, it means that
# system administrator put something there. It is very
# stupid, but will of user is sacred, and directory is
# left as-is in such case.
#
# NOTE: Non-POSIX option is used. The day coreutils will
# no longer be essential, it will require a fix.
rmdir --ignore-fail-on-non-empty "$supervise"
fi
done
}
"$@"
|