#!/bin/sh

set -x


case $2 in 
    PRE-INSTALL)

	UB_GROUP="%%UB_GROUP%%"
	UB_OWNER="%%UB_OWNER%%"
	UB_GROUP_ID="%%UB_GROUP_ID%%"
	UB_OWNER_ID="%%UB_OWNER_ID%%"

	PKG_PREFIX="%%PREFIX%%"

	UB_NAME="unbound"
	UB_SHELL="/usr/sbin/nologin"

	UB_RUNDIR="%%UB_RUNDIR%%"

	pw group add ${UB_GROUP}  -g ${UB_GROUP_ID}
	pw group show ${UB_GROUP}
	pw user add ${UB_OWNER} -u ${UB_OWNER_ID} \
	    -g ${UB_GROUP}  \
	    -d ${PKG_PREFIX} \
	    -s "${UB_SHELL}" -u ${UB_OWNER_ID} \
	    -c "${UB_NAME}"
	pw group mod ${UB_GROUP} -M ${UB_OWNER}
	pw user show ${UB_OWNER}
	pw group show ${UB_GROUP}
	install -d -o ${UB_OWNER} -g ${UB_GROUP} -m 0755 ${UB_RUNDIR}
	;;
    POST-INSTALL)
	;;
esac
exit 0
#EOF
