#!/bin/sh
### BEGIN INIT INFO
# Provides:          bugzilla
# Required-Start:    $local_fs $remote_fs $network $syslog
# Required-Stop:     $local_fs $remote_fs $network $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start/stop standalone Bugzilla server.
### END INIT INFO

PATH=/sbin:/bin:/usr/sbin:/usr/bin
PIDFILE=/var/run/bugzilla.pid
DIR=/home/www/localhost/bugs3
CONFIG=$DIR/HTTP_Prefork.conf
NAME=bugzilla

. /lib/lsb/init-functions

export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8

case "$1" in
	start)
		log_daemon_msg "Starting Bugzilla server" $NAME
		perl -T $DIR/HTTPServerSimple.pl $CONFIG --background
		log_end_msg $?
		;;
	stop)
		log_daemon_msg "Stopping Bugzilla server" $NAME
		if [ -e $PIDFILE ]; then
			kill `cat $PIDFILE` 2>/dev/null >/dev/null && rm $PIDFILE
			log_end_msg $?
		else
			echo -n ...not running
			log_end_msg 0
		fi
		;;
	restart|force-reload)
		log_daemon_msg "Restarting Bugzilla server" $NAME
		[ -e $PIDFILE ] && kill `cat $PIDFILE` 2>/dev/null >/dev/null && sleep 1 && rm $PIDFILE
		perl -T $DIR/HTTPServerSimple.pl $CONFIG --background
		log_end_msg $?
		;;
	*)
		echo "Usage: $0 {start|stop|restart|force-reload}"
		exit 1
		;;
esac

exit 0
