#!/bin/sh -e

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

# source dbconfig-common stuff
dbc_dbtypes="mysql, pgsql"

if [ -f /usr/share/dbconfig-common/dpkg/frontend.postrm ]; then
    . /usr/share/dbconfig-common/dpkg/frontend.postrm
    dbc_go acidbase $@
fi

if [ "$1" = "purge" ]; then
    rm -f /etc/acidbase/database.php
    if which ucf >/dev/null 2>&1; then
        ucf --purge /etc/acidbase/database.php
        ucfr --purge acidbase /etc/acidbase/database.php
    fi
fi

db_get acidbase/webserver || true
WEBSERVER="$RET"
case "$WEBSERVER" in
    Apache)        webservers="apache" ;;
    Apache2)       webservers="apache2" ;;
    Apache-SSL)    webservers="apache-ssl" ;;
    All)           webservers="apache apache-ssl apache2" ;;
    *)             webservers="" ;;
esac

for apache in $webservers; do
    if [ -f "/etc/$apache/conf.d/acidbase.conf" ]; then
        rm -f /etc/$apache/conf.d/acidbase.conf
        if [ -f "/var/run/$apache.pid" ]; then
            invoke-rc.d $apache reload
        fi
    fi
done


# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#
