#!/bin/sh
#
# Init file for SQuaLe
#
# chkconfig: 2345 30 70
# description: SQuaLe persistent database connection daemon
#
# processname: squale
# config: @SYSCONFDIR@/squale.xml

# Source function library.
. /etc/rc.d/init.d/functions
                                                                                
# Source networking configuration.
. /etc/sysconfig/network

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

RETVAL=0

prog="squale"

start() {
	# We don't want multiple instances fighting to run
	[ -f /var/lock/subsys/$prog ] && stop
	echo -n $"Starting $prog: "
	daemon --user squale $prog
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
}

stop() {
	echo -n $"Shutting down $prog: "
	killproc $prog
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
}

case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  restart)
	stop
	start
	;;
  condrestart)
	if [ -f /var/lock/subsys/$prog ]; then
	  stop
	  start
	  RETVAL=$?
	fi
	;;
  status)
	status $prog
	RETVAL=$?
	;;
  *)
	echo $"Usage: $0 {start|stop|restart|condrestart|status}"
	RETVAL=1
esac

exit $RETVAL
