#!/bin/sh

case $2 in
POST-INSTALL)
	USER=haldaemon
	GROUP=${USER}

	/usr/bin/install -d -o ${USER} -g ${GROUP} /var/run/hald
	/usr/bin/install -d -o ${USER} -g ${GROUP} /var/cache/hald
	/usr/bin/install -d -o ${USER} -g ${GROUP} /var/lib/hal
	%%LOCALBASE%%/bin/polkit-auth --user ${USER} --grant \
		org.freedesktop.policykit.read

	for pair in %%RC_FILES%%; do
		file=`echo $pair | cut -f 1 -d :`
		destdir=`echo $pair | cut -f 2 -d :`

		if [ ! -f $destdir/$file ]; then
	    		mkdir -p $destdir
			cp -p %%DATADIR%%/dist/$file $destdir/$file
		fi
	done
	exit 0
	;;
esac