#!/bin/sh
# Jim McDonald - 2009-05-26
# apache - preremove script
# This will shut down the application if it is running
# and remove it from the startup configuration

APPLICATION="apache"
MANIFESTDIR=/var/svc/manifest/application/${APPLICATION}
SVCENTITY="svc:/application/webserver/apache:default"
STATE="`/usr/bin/svcs -a | grep "${SVCENTITY}" | awk '{print $1}'"

if [ -x /usr/sbin/svcadm ]; then

	if [ "${STATE}" = "online" ];then
		echo "Shutting down service"
		/usr/sbin/svcadm disable ${SVCENTITY}

	fi

else
	echo "Couldn't find the service admin tool [svcadm]"
	echo "You will need to manually disable${APPLICATION}"
	echo "if it is still running"

fi

if [ -x /usr/sbin/svccfg ]; then
	echo "Removing service from SMF"
	/usr/sbin/svccfg -v delete -f ${SVCENTITY}

else
	echo "Couldn't find configuration tool for SMF"
	echo "You will need to manually remove ${APPLICATION}"
	echo "from the startup configuration"

fi
