#!/bin/sh -e

# Debian alternc-cacti postinst
# Benjamin Sonntag <benjamin@alternc.org>

# Uses debconf
. /usr/share/debconf/confmodule
# Uses AlternC.conf
if [ -r /etc/alternc/local.sh ] 
then
    . /etc/alternc/local.sh
fi

case "$1" in
configure)
	## for older alternc version
    if [ -z "$MYSQL_HOST" ]
	then
	MYSQL_HOST="localhost"
    fi
    # 1st, configure the table __if required__ The added stid will fail if it is a reinstall, whatever ...
    mysql -h"$MYSQL_HOST" -p"$MYSQL_PASS" -u"$MYSQL_USER" "$MYSQL_DATABASE" </usr/share/alternc/cacti.sql || true

    db_get alternc-cacti/postconfiguration || true

    # Compile the po files : 
    /usr/share/alternc/install/dopo.sh || true
    /etc/init.d/apache reload || true
    /etc/init.d/apache-ssl reload || true

    ;;

abort-upgrade)
    exit 0
    ;;

abort-remove|abort-deconfigure)
    exit 0
    ;;

*)
    echo "postinst called with unknown argument '$1'" >&2
    exit 1
    ;;
esac

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

#DEBHELPER#

exit 0
