#!/bin/sh
# preinst script
#
# see: dh_installdeb(1)

set -e

U_UID='1047'
U_NAME='hbf'
U_HOME='/var/run/hbf'

case "$1" in
    install|upgrade)

    # Create user and group ${U_NAME} if does not exist
    if ! getent group ${U_NAME} >/dev/null; then
        groupadd -g ${U_UID} ${U_NAME}
    else
        echo "${U_NAME} group already exists"
    fi

    if ! getent passwd ${U_NAME}>/dev/null; then
        useradd --uid ${U_UID} --gid ${U_UID} --system --no-create-home --shell /bin/false --home-dir ${U_HOME} ${U_NAME}
    else
        echo "${U_NAME} user already exists"
    fi
    ;;

    abort-upgrade)
    ;;

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

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#
exit 0
