#!/bin/sh
#
# Startup script for pygopherd, based on script for goofish
#
# chkconfig:	345 86 14
# description:	pygopherd is a simple gopher / web server.
# processname:	gopherd
# pidfile:	/var/run/pygopherd.pid
# config:	/etc/pygopherd/pygopherd.conf

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

# Get network config
. /etc/sysconfig/network

if is_yes "${NETWORKING}"; then
	if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
		msg_network_down pygopherd
		exit 1
	fi
else
	exit 0
fi

# See how we were called.
case "$1" in
  start)
	if [ ! -f /var/lock/subsys/pygopherd ]; then
		msg_starting pygopherd
		pygopherd
		ok
		touch /var/lock/subsys/pygopherd
	else
		msg_already_running pygopherd
	fi
	;;
  stop)
	if [ -f /var/lock/subsys/pygopherd ]; then
		msg_stopping pygopherd
		killproc pygopherd
		rm -f /var/lock/subsys/pygopherd /var/run/pygopherd.pid >/dev/null 2>&1
	else
		msg_not_running pygopherd
	fi
	;;
  status)
	status pygopherd
	exit $?
	;;
  restart|force-reload)
	$0 stop
	$0 start
	exit $?
	;;
  *)
	msg_usage "$0 {start|stop|restart|force-reload|status}"
	exit 3
esac

exit 0
