#!/bin/sh
#
# weatherd    Start weather daemon
#
# Author:       David L Norris, <dave@webaugur.com>
#
# chkconfig: 345 90 10
# description: This script starts/stops the weather daemon.
# processname: weatherd
# pidfile: /var/run/weatherd.pid

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

# Get config.
. /etc/sysconfig/network

#Check that networking is up.
if [ ${NETWORKING} = "no" ]
then
	exit 0
fi

[ -f /usr/sbin/weatherd ] || exit 0

# See how we were called.
case "$1" in
  start)
	echo -n "Starting weatherd: "
	daemon /usr/sbin/weatherd -d -f /etc/weatherd.xml
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/weatherd
	;;
  stop)
	echo -n "Stopping weatherd: "
	killproc weatherd
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/weatherd
	;;
  restart|reload)
	$0 stop
	$0 start
	RETVAL=$?
        ;;
  status)
	status weatherd
	RETVAL=$?
	;;
  *)
	echo "Usage: weatherd {start|stop|restart|status}"
	exit 1
esac

exit $RETVAL
