#! /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 for webserver in $RET; do webserver=${webserver%,} # Currently we only support apache2 if [ "$webserver" = "apache2" ] ; then apache_remove $1 fi done # Remove dbconfig stuff added in postinst script rm -rf /usr/share/dbconfig-common/data/zoneminder # No need to manually remove the zm database, dbconfig take care of this fi if [ "$1" = "purge" ]; then # Delete a potential remaining file used in postinst script rm -f /etc/zm/zm.conf.postinst.bak # Ask the user if we have to remove the cache directory even if not empty if [ -d /var/cache/zoneminder ] \ && [ ! $(find /var/cache/zoneminder -maxdepth 0 -type d -empty 2>/dev/null) ]; then RET="" db_input high zoneminder/ask_delete || true db_go || true db_get zoneminder/ask_delete if [ "$RET" = "true" ]; then RET="" db_input high zoneminder/ask_delete_again || true db_go || true db_get zoneminder/ask_delete_again if [ "$RET" = "true" ]; then rm -rf /var/cache/zoneminder fi fi fi fi #DEBHELPER# # postrm rm may freeze without that db_stop exit 0