#!/bin/sh -e

CONFIGFILE="/etc/alternc/local.sh"
MENUFILE="/etc/alternc/menulist.txt"

case "$1" in
  remove)

    if grep -qs "menu_webalizer.php" $MENUFILE; then
	rm -f $MENUFILE.alternc_webalizer
	cat $MENUFILE | grep -v "menu_webalizer.php" >$MENUFILE.alternc_webalizer
        mv -f $MENUFILE.alternc_webalizer $MENUFILE
    fi
    ;;
  purge)
    /usr/lib/alternc/quota_delete stats || true 
    if [ -e "$CONFIGFILE" -a -x "/usr/bin/mysql" ]; then
        . "$CONFIGFILE"
        mysql -f -u"$MYSQL_USER" -p"$MYSQL_PASS" -h"$MYSQL_HOST" \
              "$MYSQL_DATABASE" -e "DROP TABLE IF EXISTS stats;"
    fi
    rm -rf /var/cache/webalizer
    ;;
esac

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