summaryrefslogtreecommitdiff
path: root/runit-helper
diff options
context:
space:
mode:
authorDmitry Bogatov <KAction@gnu.org>2017-03-02 13:48:19 +0300
committerDmitry Bogatov <KAction@gnu.org>2017-03-02 13:48:19 +0300
commit1d0b451857a58613deb0366cc3436a0bad25a938 (patch)
tree3ab33bce4b2b2dcba47c599cbcdee5433959a47b /runit-helper
parentfa229e9d6d037e08ff548b80a9b43ffded8e352a (diff)
Introduce new binary package 'runit-helper', allowing packages to access fixes and improvements in 'dh-runit' without rebuild.
Diffstat (limited to 'runit-helper')
-rwxr-xr-xrunit-helper66
1 files changed, 66 insertions, 0 deletions
diff --git a/runit-helper b/runit-helper
new file mode 100755
index 0000000..e48020b
--- /dev/null
+++ b/runit-helper
@@ -0,0 +1,66 @@
1#!/bin/sh
2# Copyright (C) 2017 Dmitry Bogatov <KAction@gnu.org>
3
4# Author: Dmitry Bogatov <KAction@gnu.org>
5
6# This program is free software; you can redistribute it and/or
7# modify it under the terms of the GNU General Public License
8# as published by the Free Software Foundation; either version 3
9# of the License, or (at your option) any later version.
10
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15
16# You should have received a copy of the GNU General Public License
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
18
19set -e
20
21postrm () {
22
23 # Following code makes sure, that after removal of package, in default
24 # setup, the only files belonged to log user, belong to root.
25 #
26 # This way user can be safely removed, solving part of #848239 (need
27 # interoperation from dh-sysuser).
28 #
29 # Sure, system administrator can make stupid thing and chown some file
30 # to log user, but consequences do not seem to be so severe. After
31 # all, with great power comes great responsibility.
32 if [ -d "/var/log/runit/$NAME" ] ; then
33 chown --recursive root:root "/var/log/runit/$NAME"
34 fi
35
36 if [ "$1" != 'purge' ] ; then
37 return
38 fi
39
40 # If runscript was never invoked, there will be no files
41 # in this directory, and `dpkg' will remove it. In this case,
42 # we have nothing to do.
43 for supervise in "/var/lib/runit/supervise/$NAME" \
44 "/var/lib/runit/log/supervise/$NAME" ; do
45 if [ -d "$supervise" ] ; then
46
47 # Actually only `down' may be absent, but it does not
48 # matter.
49
50 for file in control lock ok pid stat status down ; do
51 rm -f "$supervise/$file"
52 done
53
54 # It should be empty now. If it is not, it means that
55 # system administrator put something there. It is very
56 # stupid, but will of user is sacred, and directory is
57 # left as-is in such case.
58 #
59 # NOTE: Non-POSIX option is used. The day coreutils will
60 # no longer be essential, it will require a fix.
61 rmdir --ignore-fail-on-non-empty "$supervise"
62 fi
63 done
64}
65
66"$@"