#!/bin/sh
# postrm script for wview
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#        * <postrm> `remove'
#        * <postrm> `purge'
#        * <old-postrm> `upgrade' <new-version>
#        * <new-postrm> `failed-upgrade' <old-version>
#        * <new-postrm> `abort-install'
#        * <new-postrm> `abort-install' <old-version>
#        * <new-postrm> `abort-upgrade' <old-version>
#        * <disappearer's-postrm> `disappear' <overwriter>
#          <overwriter-version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package


case "$1" in
    purge|failed-upgrade|abort-install|abort-upgrade|disappear)
        if [ -e /var/www/wviewmgmt ]; then
            rm -f /var/www/wviewmgmt
        fi
        if [ -e /var/www/weather ]; then
            rm -f /var/www/weather
        fi
        echo -n "Delete accumulated wview weather data? (Y/N): "
        read INVAL
        if [ "x" = "x$INVAL" ]; then
            ANSWER=N
        elif [ "$INVAL" = "Y" ]; then
            ANSWER=Y
        elif [ "$INVAL" = "y" ]; then
            ANSWER=Y
        else
            ANSWER=N
        fi
        if [ "$ANSWER" = "Y" ]; then
            rm -rf /var/lib/wview
        fi
        echo -n "Delete wview configuration and possible html customizations? (Y/N): "
        read INVAL
        if [ "x" = "x$INVAL" ]; then
            ANSWER=N
        elif [ "$INVAL" = "Y" ]; then
            ANSWER=Y
        elif [ "$INVAL" = "y" ]; then
            ANSWER=Y
        else
            ANSWER=N
        fi
        if [ "$ANSWER" = "Y" ]; then
            rm -rf /etc/wview
        fi
        rm -rf /var/lib/wviewmgmt
    ;;

    remove)
        rm -f /var/www/wviewmgmt
        rm -f /var/www/weather
        rm -rf /var/lib/wviewmgmt
    ;;

    upgrade)
    ;;

    *)
        echo "postrm 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
