#!/bin/sh
#
# $NetBSD: INSTALL,v 1.3 2000/09/03 12:03:17 veego Exp $

PKGNAME=$1
STAGE=$2

AMUSER=@AMUSER@
AMGROUP=@AMGROUP@
ADDUSER=@ADDUSER@
ADDGROUP=@ADDGROUP@
CHGRP=@CHGRP@
ID=@ID@
TOUCH=@TOUCH@
RM=@RM@

case ${STAGE} in
PRE-INSTALL)
	# Group... the default's shipped with NetBSD
	# We need to check that ${AMGROUP} exists before adding the user.
	#
	${TOUCH} "/tmp/grouptestamanda.$$"
	${CHGRP} ${AMGROUP} "/tmp/grouptestamanda.$$" >/dev/null 2>&1
	if [ $? -eq 0 ]; then
		echo "Group '${AMGROUP}' already exists...proceeding."
	else
		echo "Creating '${AMGROUP}' group..."
		${ADDGROUP} ${AMGROUP}
		echo "Done."
	fi
	${RM} -f "/tmp/grouptestamanda.$$"

	${ID} ${AMUSER} >/dev/null 2>&1
	if [ $? -eq 0 ]; then
		echo "User '${AMUSER}' already exists...proceeding."
	else
		echo "Creating '${AMUSER}' user..."
		${ADDUSER} -c "Amanda User" -g ${AMGROUP} -s /bin/sh ${AMUSER}
		echo "Done."
	fi
	;;
POST-INSTALL)
	;;
*)
	echo "Unexpected argument: $2"
	exit 1
	;;
esac
exit 0
