#!/bin/sh

if [ -x /bin/systemctl ]; then
  systemctl daemon-reload >/dev/null 2>&1 || true
fi

USER="kandalf"

case "$1" in
  upgrade)
    if [ -x /bin/systemctl ]; then
      systemctl restart kandalf.service
    fi
    ;;

  remove|purge)
    update-rc.d kandalf remove -f >/dev/null
    deluser ${USER} >/dev/null
    delgroup ${USER} >/dev/null
    ;;

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

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

if [ -d /run/systemd/system ] ; then
  systemctl --system daemon-reload >/dev/null || true
fi

exit 0
