#!/bin/bash
# postrm script for jicofo

set -e

# Load debconf
. /usr/share/debconf/confmodule


case "$1" in
    purge)

        # Clear the debconf variable
        db_purge

        # clear user and group
        # ensure nothing is running as jicofo user
        if ps -u jicofo h; then
            `ps -u jicofo -o pid h | xargs kill`
        fi
        # and then remove the user
        if getent passwd jicofo > /dev/null ; then
            deluser jicofo
        fi

        # clear logs
        if [ -f "/var/log/jitsi/jicofo.log" ]; then
            rm -f "/var/log/jitsi/jicofo.log"
        fi

        rm -rf /usr/share/jicofo/
        rm -f /etc/jitsi/jicofo/config
        rm -f /etc/jitsi/jicofo/sip-communicator.properties
        rm -f /etc/jitsi/jicofo/logging.properties
        rm -f /etc/jitsi/jicofo/jicofo.conf
    ;;

    remove)
     ;;

    upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
    ;;

    *)
        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#

db_stop

exit 0
