# Start the HTTP daemon.

case $#:$1 in
1:start|1:stop)	;;
*)	echo "Usage: $0 start|stop" >&2; exit 1
esac

bin=/opt/httpd/bin
home=/var/opt/httpd

cd / || exit
test -d $home || exit 0
grep -i '^ServerType.*standalone' \
			$home/conf/httpd.conf >/dev/null 2>&1 || exit 0

case $1 in
start)
	daemonize=; test -t 0 && daemonize='intr -d'

	# Start a daemon if all the necessary pieces are there.
	if [ -f $bin/httpd -a -d $home/conf \
					-a -d $home/htdocs -a -d $home/logs ]
	then
		echo "Starting httpd."
		$daemonize $bin/httpd &
	fi
	;;
stop)
	# Stop the daemon.
	if pid=`cat $home/logs/httpd.pid 2>/dev/null` \
		&& ps -p $pid | grep httpd >/dev/null
	then
		kill $pid
	fi
	exit 0
esac
