summaryrefslogtreecommitdiff
path: root/postrm-runit
blob: cc19d381c61ed642d838d91c9640dcd9feef8742 (plain)
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
# -*- shell-script -*-

if [ "$1" = 'purge' ] ; then
    # 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-non-empty "$supervise_dir"
    fi
    unset supervise_dir
fi

# Local Variables:
# eval: (sh-set-shell "sh" t nil)
# End: