#!/bin/sh
#
# $FreeBSD: ports/www/twiki/files/pkg-install.in,v 1.5 2008/04/22 08:36:40 sat Exp $
#

TWDIR=/usr/local/share/twiki/SpreadSheetPlugin
WWWDIR=/usr/local/www/twiki
WWWOWN=www
WWWGRP=www

case $2 in
	PRE-INSTALL)
		;;
	POST-INSTALL)
		cd ${TWDIR}/
		find -s * -type d | while read dir; do
			mkdir -p ${WWWDIR}/$dir/
		done
		find -s * -not -type d | while read file; do
			if [ -e ${WWWDIR}/$file ]; then
				echo "${WWWDIR}/$file exists, skipping"
			else
				cp $file ${WWWDIR}/$file
			fi
		done
		chown -R ${WWWOWN}:${WWWGRP} ${WWWDIR}/
		chmod -R u+w ${WWWDIR}/
		cd ${WWWDIR}/
		chmod o-rwx data lib locale templates test tools working
		chmod a+x bin/* tools/*

		# let the user know what's going on
		cat << __EOF__
*****************************************************************
* You can inspect differences (if any) between the distribition *
* and the files installed using this command:                   *
  % diff -ru ${TWDIR} ${WWWDIR}
* For more info:                                                *
*  http://wiki.FreeBSD.org/TWiki                                *
*  http://twiki.org/cgi-bin/view/Codev/TWikiOnFreeBSD           *
*  http://twiki.org/cgi-bin/view/TWiki/WebHome                  *
*****************************************************************
__EOF__
		;;
	*)
		echo "Unexpected Argument $2!!!"
		exit 1
		;;
esac
exit 0
