summaryrefslogtreecommitdiff
path: root/postrm-runit
blob: 9a69a538a57ebc36a6e9f8749410c9c8526abfd5 (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
31
32
# -*- 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.
	for supervise in "/var/lib/runit/supervise/#NAME#" \
	                 "/var/lib/runit/log/supervise/#NAME#" ; do
		if [ -d "$supervise" ] ; 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/$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"
		fi
	done
fi

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