#!/bin/sh
#
# wwwoffle	Caching Web Proxy Server
#
# chkconfig: 2345 80 20
# description:	A proxy HTTP/FTP server 
#		for computers with dial-up 
#		internet access.
# processname: wwwoffled
# config: /etc/wwwoffle.conf
# pidfile: /var/run/wwwoffle.pid

# Do not load RH compatibility interface.
WITHOUT_RC_COMPAT=1

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

PIDFILE=/var/run/wwwoffle.pid
CONFIGFILE=/etc/wwwoffle.conf
LOCKFILE=/var/lock/subsys/wwwoffle
RETVAL=0


# Source networking configuration.
SourceIfNotEmpty /etc/sysconfig/network &&
	[ "$NETWORKING" != no ] &&
	[ -x $DAEMON ] &&
	[ -s $CONFIGFILE ] ||
	exit

start()
{
	start_daemon --lockfile "$LOCKFILE" --expect-user wwwoffle -- \
		wwwoffled -c "$CONFIGFILE"
	RETVAL=$?
	return $RETVAL
}

stop()
{
	stop_daemon --lockfile "$LOCKFILE" --expect-user wwwoffle -- wwwoffled
	RETVAL=$?
	return $RETVAL
}

restart()
{
	stop
	start
}

reload()
{
	msg_reloading wwwoffle
	stop_daemon --expect-user wwwoffle -HUP -- wwwoffled
	RETVAL=$?
	return $RETVAL
}

# See how we were called.
case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	reload)
		reload
		;;
	restart)
		restart
		;;
	condstop)
		if [ -e "$LOCKFILE" ]; then
			stop
		fi
		;;
	condrestart)
		if [ -e "$LOCKFILE" ]; then
			restart
		fi
		;;
	condreload)
		if [ -e "$LOCKFILE" ]; then
			reload
		fi
		;;
	status)
		status --expect-user wwwoffle -- wwwoffled
		RETVAL=$?
		;;
	*)
		msg_usage "${0##*/} {start|stop|reload|restart|condstop|condrestart|condreload|status}"
		RETVAL=1
esac

exit $RETVAL
