# $Id: postinstall,v 1.4 2006/04/26 10:45:54 elkner Exp $

if [ -z "$PKG_INSTALL_ROOT" ]; then
	BASE=$CLIENT_BASEDIR/apache2
	CFDIR=/etc/apache2
else
	BASE=${PKG_INSTALL_ROOT}$CLIENT_BASEDIR/apache2
	CFDIR=${PKG_INSTALL_ROOT}/etc/apache2
fi

if [ ! -r ${CFDIR}/httpd.conf ]; then
	cp -p ${CFDIR}/original/httpd.conf ${CFDIR}/httpd.conf
	for ORIG in magic mime.types ; do
		if [ ! -r ${CFDIR}/$ORIG ]; then
			cp -p ${CFDIR}/original/$ORIG ${CFDIR}/
		fi
	done
	for DIR in extra ssl.crl ssl.crt ssl.key ; do
		if [ ! -d ${CFDIR}/$DIR ]; then
			cp -rp ${CFDIR}/original/$DIR ${CFDIR}/
			if [ "$DIR" = "ssl.key" ]; then
				chmod 750 ${CFDIR}/$DIR
				chgrp webservd ${CFDIR}/$DIR
			fi
		else
			for ORIG in ${CFDIR}/original/$DIR/* ; do
				BN=`basename $ORIG`
				if [ ! -r ${CFDIR}/$DIR/$BN ]; then
					cp -p $ORIG ${CFDIR}/$DIR/$BN
				fi
			done
		fi
	done
fi

if [ ! -r ${BASE}/bin/envvars ]; then
	echo '# environment variables for apachectl
# required by apxs, even if it is empty' >${BASE}/bin/envvars
	chmod 0644 ${BASE}/bin/envvars
fi

echo "
To verify that Apache actually works correctly you now should
first check the configuration files in:

${CFDIR}/httpd.conf

All sample configuration files are installed ${CFDIR}/original/.
To enable/disable the server at boot time, just use 

	svcadm {enable|disable} apache2

"
