zoneminder/distros/debian8/zoneminder.postrm

60 lines
1.6 KiB
Bash

#! /bin/sh
# postrm maintainer script for zoneminder
set -e
# Source the debconf stuff
if [ -f /usr/share/debconf/confmodule ]; then
. /usr/share/debconf/confmodule
fi
apache_remove() {
COMMON_STATE=$(dpkg-query -f '${Status}' -W 'apache2.2-common' 2>/dev/null | awk '{print $3}' || true)
if [ -e /usr/share/apache2/apache2-maintscript-helper ] ; then
. /usr/share/apache2/apache2-maintscript-helper
apache2_invoke disconf zoneminder
elif [ "$COMMON_STATE" = "installed" ] || [ "$COMMON_STATE" = "unpacked" ] ; then
rm -f /etc/apache2/conf.d/zoneminder.conf
fi
rm -f /etc/apache2/conf-available/zoneminder.conf
# Reload the web server
deb-systemd-invoke reload apache2.service || true
}
# Source the dbconfig stuff
if [ -f /usr/share/dbconfig-common/dpkg/postrm ]; then
. /usr/share/dbconfig-common/dpkg/postrm
# Ask the user what do to with dbconfig when removing the package
dbc_go zoneminder $@
fi
if [ "$1" = "remove" ] || [ "$1" = "purge" ]; then
# Deconfigure the web server
db_get zoneminder/webserver
webservers="$RET"
for webserver in $webservers; do
webserver=${webserver%,}
# Currently we only support apache2
if [ "$webserver" = "apache2" ] ; then
apache_remove $1
fi
done
# No need to manually remove the zm database and user, dbconfig take care of this
fi
if [ "$1" = "purge" ]; then
# Delete a potential remaining file not managed by debhelper
rm -f /etc/zm/zm.conf.postinst.bak
fi
#DEBHELPER#
# postrm rm may freeze without that
db_stop
exit 0