#!/bin/sh
#
# $NetBSD: INSTALL,v 1.1 2000/07/26 19:03:23 jlam Exp $

PKGNAME=$1
STAGE=$2

case ${STAGE} in
PRE-INSTALL)
	;;
POST-INSTALL)
	ETCDIR=/etc/netatalk

	mkdir -p ${ETCDIR}

	# The idea is to copy old config files over to the new location if
	# they exist.  Otherwise, copy the default config from the examples
	# directory.
	#
	if [ -f ${PKG_PREFIX}/etc/atalkd.conf ]
	then
		for file in \
			AppleVolumes.default \
			AppleVolumes.system \
			atalkd.conf \
			papd.conf
		do
			if [ ! -f ${ETCDIR}/${file} -a -f ${PKG_PREFIX}/etc/${file}]
			then
				echo "  ${ETCDIR}/${file}"
				cp ${PKG_PREFIX}/etc/${file} ${ETCDIR}/${file}
				chmod 644 ${ETCDIR}/${file}
			fi
		done
		echo "done."
		cat << EOF
===========================================================================
Old configuration files were copied from ${PKG_PREFIX}/etc to
${ETCDIR}.  You may want to remove the old files as they are no
longer necessary.
===========================================================================
EOF
	else
		echo "Installing configuration files:"
		for file in \
			AppleVolumes.default \
			AppleVolumes.system \
			atalkd.conf \
			papd.conf
		do
			if [ -f ${ETCDIR}/${file} ]
			then
				echo "  ${ETCDIR}/${file} already exists"
			else
				echo "  ${ETCDIR}/${file}"
				cp ${PKG_PREFIX}/share/examples/netatalk/${file} \
					${ETCDIR}/${file}
				chmod 644 ${ETCDIR}/${file}
			fi
		done
		echo "done."
	fi
	;;
*)
	echo "Unexpected argument: ${STAGE}"
	exit 1
	;;
esac
exit 0
