#!/bin/sh
#
# Startup script for the Compaq Configurator
#
# chkconfig: 345 85 15
# description: This program allows a Compaq web appliance to be configured.
#	       
# processname: cpqcfg
# pidfile: /var/run/cpqcfg.pid
# config: /var/cpqcfg/httpd/conf/access.conf
# config: /var/cpqcfg/httpd/conf/cpqcfg.conf
# config: /var/cpqcfg/httpd/conf/srm.conf

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

# Path to the httpd binary.
cpqcfg=/var/cpqcfg/httpd/cpqcfg
RETVAL=0

# Until glibc's locale support is working right again, work around it.
LANG=C

start() {
	echo -n "Starting cpqcfg: "
	daemon ${cpqcfg} '-f /var/cpqcfg/httpd/conf/cpqcfg.conf -D HAVE_SSL'
	RETVAL=$?
	echo
	[ $RETVAL = 0 ] && touch /var/cpqcfg/httpd/lock/cpqcfg
	return $RETVAL
}
stop() {
	echo -n "Shutting down cpqcfg: "
	killproc cpqcfg
	RETVAL=$?
	echo
	[ $RETVAL = 0 ] && rm -f /var/cpqcfg/httpd/lock/cpqcfg /var/run/cpqcfg.pid
}

# See how we were called.
case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  status)
	status ${cpqcfg}
	;;
  restart)
	stop
	start
	;;
  reload)
	echo -n "Reloading cpqcfg: "
	killproc ${cpqcfg} -HUP
	RETVAL=$?
	echo
	;;
  condrestart)
	if [ -f /var/cpqcfg/httpd/run/cpqcfg.pid ] ; then
		stop
		start
	fi
	;;
  *)
	echo "Usage: $0 {start|stop|restart|reload|condrestart|status}"
	exit 1
esac

exit $RETVAL
