#!/bin/sh
#
# piranha-gui	This script handles the starting and stopping of the
#		apache server used for the piranha gui (http://localhost:3636/)
#		(Not terribly well done because it's difficult to distinguish
#		between the normal webserver and the piranha copy)
#
# chkconfig: - 60 10
# description:  pulse is the controlling daemon that spawns off the lvs \
#		daemon as well as heartbeating and monitoring of services \
#		on the real servers.
# processname: httpd
# pidfile: /etc/sysconfig/ha/logs/piranha-httpd.pid
# config: /etc/sysconfig/ha/conf/httpd.conf

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0

# Make sure apache is available
[ -f /usr/sbin/httpd ] || exit 0

# Make sure that there is an lvs.cf to work from
[ -f /etc/sysconfig/ha/lvs.cf ] || exit 0

# See how we were called.
case "$1" in
  start)
        echo -n "Starting piranha-gui: "
	if [ -f /usr/lib/apache/libphp3.so ] ; then
	        /usr/sbin/httpd -D HAVE_PHP3 -f /etc/sysconfig/ha/conf/httpd.conf
	fi
	if [ -f /usr/lib/apache/libphp4.so ] ; then
		/usr/sbin/httpd -D HAVE_PHP4 -f /etc/sysconfig/ha/conf/httpd.conf
	fi
        echo
        touch /var/lock/subsys/piranha-gui
        ;;

  stop)
        echo -n "Shutting down piranha-gui: "
	PID=`head -1 /etc/sysconfig/ha/logs/piranha-httpd.pid`
	kill -SIGTERM $PID
        echo
        ;;

  *)
        echo "Usage: piranha-gui: {start|stop}"
        exit 1
esac

exit 
