#!/bin/sh
# PyRSS - Jabber headlines service
#
# chkconfig:	345 85 05
# description:	PyRSS - Jabber headlines service

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

# Get network config
. /etc/sysconfig/network

# Get service config
[ -f /etc/sysconfig/pyrss ] && . /etc/sysconfig/pyrss

# Check that networking is up.
if is_yes "${NETWORKING}"; then
	if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
		msg_network_down pyrss
		exit 1
	fi
else
	exit 0
fi

RETVAL=0
# See how we were called.
case "$1" in
  start)
	# Check if the service is already running?
	if [ ! -f /var/lock/subsys/pyrss ]; then
		msg_starting "PyRSS"
		daemon /usr/sbin/daemon -D /var/lib/ -u jabber \
			-P /var/run/jabber -r -n pyrss /usr/sbin/pyrss
		RETVAL=$?
		[ $RETVAL -eq 0 ] && touch /var/lock/subsys/pyrss
	else
		msg_already_running pyrss
	fi
	;;
  stop)
	# Check if the service is already running?
	if [ -f /var/lock/subsys/pyrss ]; then
		msg_stopping "PyRSS"
		busy
		/usr/sbin/daemon -P /var/run/jabber --stop -n pyrss && ok || fail
		rm -f /var/lock/subsys/pyrss
	else
		msg_not_running pyrss
	fi
	;;
  restart|force-reload)
	$0 stop
	$0 start
	exit $?
	;;
  status)
	status pyrss
	/usr/sbin/daemon -P /var/run/jabber --verbose --running -n pyrss
	exit $?
	;;
  *)
	msg_usage "$0 {start|stop|restart|force-reload|status}"
	exit 3
esac

exit $RETVAL
