#!/bin/sh

set -e

. /usr/share/debconf/confmodule

db_get killbill/username && KILLBILL_USER="$RET" || KILLBILL_USER="killbill"
db_get killbill/groupname && KILLBILL_GROUP="$RET" || KILLBILL_GROUP="killbill"

# /etc/default/killbill-server has been deleted already
KILLBILL_LOG_DIR=/var/log/killbill

case "$1" in
    purge)
        # Remove killbill user and group
        userdel ${KILLBILL_USER} || true
        # Remove log files (see http://www.debian.org/doc/debian-policy/ch-files.html)
        rm -rf ${KILLBILL_LOG_DIR} || true
        # Remove my changes to the debconf db
        db_purge
    ;;
    remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
    ;;

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

#DEBHELPER#

exit 0
