#!/bin/sh
set -e

. /usr/share/debconf/confmodule

case "$1" in
    configure)
        # Create numerus user and group
        if ! getent group numerus >/dev/null; then
            addgroup --system --quiet numerus
        fi
        if ! getent passwd numerus >/dev/null; then
            adduser --quiet \
                    --system \
                    --disabled-login \
                    --no-create-home \
                    --shell /bin/bash \
                    --ingroup numerus \
                    --home /usr/share/numerus \
                    --gecos "Numerus Daemon" \
                    numerus
        fi

        # Make sure log directory has correct permissions set
        dpkg-statoverride --list "/var/log/numerus" >/dev/null || \
            dpkg-statoverride --add --force --quiet --update numerus adm 0750 /var/log/numerus
        ;;

  abort-upgrade|abort-remove|abort-deconfigure)
        ;;

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

#DEBHELPER#

exit 0
