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 | |
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.
-rw-r--r-- | debian/changelog | 3 | ||||
-rw-r--r-- | postrm-runit | 30 |
2 files changed, 25 insertions, 8 deletions
diff --git a/debian/changelog b/debian/changelog index 28bf913..3d0147a 100644 --- a/debian/changelog +++ b/debian/changelog | |||
@@ -2,6 +2,9 @@ dh-runit (0.4) UNRELEASED; urgency=medium | |||
2 | 2 | ||
3 | * Fix bug, that caused dh-runit to attemt to create directory | 3 | * Fix bug, that caused dh-runit to attemt to create directory |
4 | under /. | 4 | under /. |
5 | * Fix postrm script. Previously, it halted purge with errors about | ||
6 | missing supervise directory. Indeed, if service was never started, | ||
7 | it's supervise directory is empty and removed by dpkg. | ||
5 | 8 | ||
6 | -- Dmitry Bogatov <KAction@gnu.org> Thu, 28 Jul 2016 15:36:43 +0300 | 9 | -- Dmitry Bogatov <KAction@gnu.org> Thu, 28 Jul 2016 15:36:43 +0300 |
7 | 10 | ||
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: |