File tinyproxy.init of Package tinyproxy

#! /bin/sh
#
# /etc/init.d/tinyproxy
#   and symbolic its link
# (usr/)sbin/rctinyproxy
#
# System startup script for the tiny http proxy
#
### BEGIN INIT INFO
# Provides:          tinyproxy
# Required-Start:    $remote_fs $syslog $named
# Required-Stop:     $remote_fs $syslog $named
# Default-Start:     3 5
# Default-Stop:      0 1 2 6
# Short-Description: Start tiny http-proxy
# Description:       tinyproxy is a GPLed, lightweight HTTP proxy.
#       Designed from the ground up to be fast and yet small, it
#       is an ideal solution for sites where a full-featured HTTP
#       proxy is required, but the system resources required to
#       run a more demanding HTTP proxy are unavailable.
### END INIT INFO
#
# Return values acc. to LSB for all commands but status:
# 0 - success
# 1 - generic or unspecified error
# 2 - invalid or excess argument(s)
# 3 - unimplemented feature (e.g. "reload")
# 4 - insufficient privilege
# 5 - program is not installed
# 6 - program is not configured
# 7 - program is not running
# 
# Note that starting an already running service, stopping
# or restarting a not-running service as well as the restart
# with force-reload (in case signalling is not supported) are
# considered a success.

TINYPROXY_BIN=/usr/sbin/tinyproxy
test -x $TINYPROXY_BIN || { echo "$TINYPROXY_BIN not installed";
	if [ "$1" = "stop" ]; then exit 0;
	else exit 5; fi; }

TINYPROXY_CFG=/etc/tinyproxy.conf
test -r $TINYPROXY_CFG || { echo "$TINYPROXY_CFG not existing";
	if [ "$1" = "stop" ]; then exit 0;
	else exit 6; fi; }

TINYPROXY_PID=/var/run/tinyproxy/tinyproxy.pid

# create DIR for PID
[ ! -d /var/run/tinyproxy ] && {
	install -d -m0750 -o tinyproxy -g root /var/run/tinyproxy; }

TINYPROXY="tiny http proxy"

# Shell functions sourced from /etc/rc.status:
#      rc_check         check and set local and overall rc status
#      rc_status        check and set local and overall rc status
#      rc_status -v     ditto but be verbose in local rc status
#      rc_status -v -r  ditto and clear the local rc status
#      rc_failed        set local and overall rc status to failed
#      rc_failed <num>  set local and overall rc status to <num><num>
#      rc_reset         clear local rc status (overall remains)
#      rc_exit          exit appropriate to overall rc status
. /etc/rc.status

# First reset status of this service
rc_reset

case "$1" in
start)
	echo -n "Starting $TINYPROXY: "
	/sbin/startproc -p $TINYPROXY_PID $TINYPROXY_BIN

	# Remember status and be verbose
	rc_status -v
        ;;
stop)
	echo -n "Shutting down $TINYPROXY: "
	/sbin/killproc -p $TINYPROXY_PID -TERM $TINYPROXY_BIN

	# Remember status and be verbose
	rc_status -v
        ;;
try-restart)
	$0 status >/dev/null &&  $0 restart

	# Remember status and be quiet
	rc_status
        ;;
restart)
	$0 stop
	$0 start

	# Remember status and be quiet
	rc_status
        ;;
force-reload)
	echo -n "Reload service $TINYPROXY: "
	/sbin/killproc -p $TINYPROXY_PID -HUP $TINYPROXY_BIN

	# Remember status and be verbose
	rc_status -v
        ;;
reload)
	echo -n "Reload service $TINYPROXY: "
	/sbin/killproc -p $TINYPROXY_PID -HUP $TINYPROXY_BIN

	# Remember status and be verbose
	rc_status -v
        ;;
status)
	echo -n "Checking for $TINYPROXY: "
	/sbin/checkproc -p $TINYPROXY_PID $TINYPROXY_BIN

	# Remember status and be verbose
	rc_status -v
        ;;
probe)
	test $TINYPROXY_CFG -nt $TINYPROXY_PID && echo reload
        ;;
*)
	echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
	exit 1
        ;;
esac
rc_exit

openSUSE Build Service is sponsored by