#!/bin/sh
#
# tiarra - irc proxy server
#
# chkconfig:   - 85 15
# description: Tiarra is pure-perl irc proxy(or bot) software, with single-thread, \
#              multi-io, object-oriented framework.
# processname: tiarra
# config:      /etc/tiarra/tiarra.conf
# pidfile:     /var/run/tiarra.pid

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

# Check that networking is up.
. /etc/sysconfig/network
[ "$NETWORKING" = "no" ] && exit 0

tiarra=/usr/bin/tiarra
prog=$(basename $tiarra)
tiara_conf="/etc/tiarra/tiarra.conf"
lockfile=/var/lock/subsys/tiarra

#[ -f /etc/sysconfig/tiarra ] && . /etc/sysconfig/tiarra

start() {
	[ -x $tiarra ] || exit 5
	[ -f $tiara_conf ] || exit 6
	echo -n $"Starting $prog: "	
	daemon $tiarra --config=$tiara_conf --quiet
	retval=$?
	echo
	[ $retval -eq 0 ] && touch $lockfile
	return $retval
}

stop() {
	echo -n $"Stopping $prog: "
	killproc $prog
	retval=$?
	echo
	[ $retval -eq 0 ] && rm -f $lockfile
    return $retval
}

restart() {
	stop
	start
}	

reload() {
	echo -n $"Reloading $prog:"
	killproc $prog -HUP
	echo
}	

case "$1" in
start)
	start
	;;
stop)
	stop
	;;
reload)
	reload
	;;
restart)
	restart
	;;
condrestart)
	[ -f $lockfile ] && restart || :
	;;
status)
	status $prog
	;;
*)
	echo $"Usage: $0 {start|stop|reload|restart|condrestart|status}"
	exit 2
esac

