#!/bin/sh -e

CONFIGFILE="/etc/alternc/my.cnf"
MENUFILE="/etc/alternc/menulist.txt"

case "$1" in
  remove)

    # TODO : we don't purge *-ssl vhosts or *-ssl templates, they may break the hosting ...
    if [ -e "$CONFIGFILE" -a -x "/usr/bin/mysql" ]; then
        mysql --defaults-file=${CONFIGFILE} -f -e "DELETE FROM domaines_type WHERE name IN ('vhost-ssl','vhost-mixssl','roundcube-ssl','squirrelmail-ssl','panel-ssl','php52-ssl','php52-mixssl');"
        mysql --defaults-file=${CONFIGFILE} -f -e "UPDATE sub_domaines SET web_action='DELETE' WHERE type IN ('vhost-ssl','vhost-mixssl','roundcube-ssl','squirrelmail-ssl','panel-ssl','php52-ssl','php52-mixssl');"
    fi
    echo -e "\033[31m**********************************************"
    echo "*                                            *"
    echo "*   ALTERNC-SSL    ACTION REQUESTED          *"
    echo "*                                            *"
    echo "* Please run alternc.install to fully remove *"
    echo "*                                            *"
    echo "**********************************************"
    echo -e "\033[0m"

;;
  purge)
    # Purge the certificate and alias table:
    if [ -e "$CONFIGFILE" -a -x "/usr/bin/mysql" ]; then
       mysql --defaults-file=${CONFIGFILE} -f -e "DROP TABLE IF EXISTS certificate;"
       mysql --defaults-file=${CONFIGFILE} -f -e "DROP TABLE IF EXISTS certif_alias;"
       mysql --defaults-file=${CONFIGFILE} -f -e "DROP TABLE IF EXISTS certif_hosts;"
    fi
    ;;
esac

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