#!/bin/sh
#
# $NetBSD$

add_uuid() {
	if ! test -f "$1"; then
		return 0
	fi
	if grep "^[[:blank:]]*uuid[[:blank:]]*=" "$1" > /dev/null; then
		return 0
	fi
	UUIDGEN=`which uuidgen`
	if [ "$UUIDGEN" = "" ]; then
		echo "WARNING: uuidgen(1) not found, please add uuids to your xtreemfs configuration files manually."
		return 0
	fi
	echo "" >> "$1"
	echo "# uuid generated by pkgsrc" >> "$1"
	echo "uuid = `$UUIDGEN`" >> "$1"
}

case ${STAGE} in
POST-INSTALL)
	add_uuid "${PKG_SYSCONFDIR}/dirconfig.properties"
	add_uuid "${PKG_SYSCONFDIR}/mrcconfig.properties"
	add_uuid "${PKG_SYSCONFDIR}/osdconfig.properties"
	;;
esac
