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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
#!/bin/sh
set -e
is_up () {
# stat --> run | down
if [ -e "/etc/service/$name/supervise/stat" ]; then
stat=$(cat "/etc/service/$name/supervise/stat")
if [ "$stat" != run ]; then
return 1
else
return 0
fi
else
return 1
fi
}
if [ "$1" = remove ]; then
for path in /etc/service/* ; do
name=$(basename "$path")
if [ -r /etc/service/"$name"/.meta/pkg ]; then
ispkg=$(cat /etc/service/"$name"/.meta/pkg)
if [ "$ispkg" != 'runit-services' ]; then
continue # skip: not from this package
fi
else
continue # skip: not from this package
fi
if [ -z "${DPKG_ROOT:-}" ] ; then
ENABLE=yes #irrelevant for prerm
if [ -r /etc/service/"$name"/.meta/onupgrade ]; then
onupgrade=$(cat /etc/service/"$name"/.meta/onupgrade)
if [ "$onupgrade" = "nostop" ] || [ "$onupgrade" = 'reload' ]; then
if is_up ; then
echo "warning: stop $name is dangerous, skipping"
echo "Please stop $name manually from a getty"
fi
continue
fi
else
onupgrade=restart #dh default
fi
NAME=$name ENABLE=yes ONUPGRADE=$onupgrade \
/lib/runit-helper/runit-helper prerm "$@"
fi
done
fi
#DEBHELPER#
exit 0
|