diff options
author | Dmitry Bogatov <KAction@gnu.org> | 2016-07-28 16:08:56 +0300 |
---|---|---|
committer | Dmitry Bogatov <KAction@gnu.org> | 2016-07-28 16:08:56 +0300 |
commit | c360e821d2b77e7e81e6b39512474cc4f3b47b05 (patch) | |
tree | 2d6ca0ad3ead805fb1f6da9a12e710a3f65a366f /postrm-runit | |
parent | 7a6bfb4bbee9c224d5fd7b3fe62c7234a6804250 (diff) |
Fix postrm script. Previously, it halted purge with errors about missing supervise directory. Indeed, if service was never started, it's supervise directory is empty and removed by dpkg.
Diffstat (limited to 'postrm-runit')
-rw-r--r-- | postrm-runit | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/postrm-runit b/postrm-runit index 3e3d76d..d07049c 100644 --- a/postrm-runit +++ b/postrm-runit | |||
@@ -1,14 +1,28 @@ | |||
1 | # -*- shell-script -*- | 1 | # -*- shell-script -*- |
2 | 2 | ||
3 | if [ "$1" = 'purge' ] ; then | 3 | if [ "$1" = 'purge' ] ; then |
4 | # If runscript was never invoked, these files would not exist, | 4 | # If runscript was never invoked, there will be no files |
5 | # so we use -f option of rm(1). | 5 | # in this directory, and `dpkg' will remove it. In this case, |
6 | for file in control lock ok pid stat status ; do | 6 | # we have nothing to do. |
7 | rm -f "/var/lib/runit/supervise/#NAME#/$file" | 7 | supervise_dir="/var/lib/runit/supervise/#NAME#" |
8 | done | 8 | if [ -d "$supervise_dir" ] ; then |
9 | # It should exist and be empty now. If it is not, either user touched it, | 9 | |
10 | # or there is a BUG in dh-runit! | 10 | # Actually only `down' may be absent, but it does not |
11 | rmdir "/var/lib/runit/supervise/#NAME#" | 11 | # matter. |
12 | |||
13 | for file in control lock ok pid stat status down ; do | ||
14 | rm -f "$supervise_dir/$file" | ||
15 | done | ||
16 | |||
17 | # It should be empty now. If it is not, it means that system administrator put | ||
18 | # something there. It is very stupid, but will of user is sacred, and directory | ||
19 | # is left as-is in such case. | ||
20 | # | ||
21 | # NOTE: Non-POSIX option is used. The day coreutils will no longer be essential, | ||
22 | # it will require a fix. | ||
23 | rmdir --ignore-fail-on-nonempty "$supervise_dir" | ||
24 | fi | ||
25 | unset supervise_dir | ||
12 | fi | 26 | fi |
13 | 27 | ||
14 | # Local Variables: | 28 | # Local Variables: |