#!/sbin/sh
#
# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
#ident	"@(#)apache.sh	1.4	04/08/24 SMI"

APACHE_HOME=/usr/apache
CONF_FILE=/etc/apache/httpd.conf
RUNDIR=/var/run/apache
PIDFILE=${RUNDIR}/httpd.pid

if [ ! -f ${CONF_FILE} ]; then
	exit 0
fi

if [ ! -d ${RUNDIR} ]; then
	/usr/bin/mkdir -p -m 755 ${RUNDIR}
fi

case "$1" in
start)
	/bin/rm -f ${PIDFILE}
	cmdtext="starting"
	;;
restart)
	cmdtext="restarting"
	;;
stop)
	cmdtext="stopping"
	;;
*)
	echo "Usage: $0 {start|stop|restart}"
	exit 1
	;;
esac

echo "httpd $cmdtext."

/bin/sh -c "${APACHE_HOME}/bin/apachectl $1" 2>&1 &
status=$?

if [ $status != 0 ]; then
	echo "exit status $status"
	exit 1
fi
exit 0
