#! /bin/sh
# postrm maintainer script for zoneminder-db package

set -e

# Source the debconf stuff
if [ -f /usr/share/debconf/confmodule ]; then
    . /usr/share/debconf/confmodule
fi

# 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
    # 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
fi

#DEBHELPER#

# postrm rm may freeze without that
db_stop

exit 0
