#!/sbin/sh
#
# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
#ident	"@(#)apache.sh	1.5	05/01/10 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."

${APACHE_HOME}/bin/apachectl $1 2>&1 &
status=$?

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