#!/bin/sh

set -e

[ -f /etc/default/alloy ] && . /etc/default/alloy

case "$1" in
  remove)
    [ -z "$ALLOY_USER" ] && ALLOY_USER="alloy"
    [ -z "$ALLOY_GROUP" ] && ALLOY_GROUP="alloy"
    if getent passwd "$ALLOY_USER" > /dev/null 2>&1 ; then
      deluser --quiet --system "$ALLOY_USER" || true
    fi
    if getent group "$ALLOY_GROUP" > /dev/null 2>&1 ; then
      delgroup --quiet --system --only-if-empty "$ALLOY_GROUP" || true
    fi
    ;;
  purge)
    rmdir /etc/alloy /var/lib/alloy || true
    ;;
esac

#DEBHELPER#
