From c360e821d2b77e7e81e6b39512474cc4f3b47b05 Mon Sep 17 00:00:00 2001 From: Dmitry Bogatov Date: Thu, 28 Jul 2016 16:08:56 +0300 Subject: 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. --- postrm-runit | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'postrm-runit') diff --git a/postrm-runit b/postrm-runit index 3e3d76d..d07049c 100644 --- a/postrm-runit +++ b/postrm-runit @@ -1,14 +1,28 @@ # -*- shell-script -*- if [ "$1" = 'purge' ] ; then - # If runscript was never invoked, these files would not exist, - # so we use -f option of rm(1). - for file in control lock ok pid stat status ; do - rm -f "/var/lib/runit/supervise/#NAME#/$file" - done - # It should exist and be empty now. If it is not, either user touched it, - # or there is a BUG in dh-runit! - rmdir "/var/lib/runit/supervise/#NAME#" + # 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. + supervise_dir="/var/lib/runit/supervise/#NAME#" + if [ -d "$supervise_dir" ] ; 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_dir/$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-nonempty "$supervise_dir" + fi + unset supervise_dir fi # Local Variables: -- cgit v1.2.3