forked from pool/squid
69403394b4
recover old spec, fix permissions for SLE11 OBS-URL: https://build.opensuse.org/request/show/286695 OBS-URL: https://build.opensuse.org/package/show/server:proxy/squid?expand=0&rev=65
202 lines
5.5 KiB
Bash
202 lines
5.5 KiB
Bash
#!/bin/sh
|
|
# Copyright (c) 1996, 1997, 1998 S.u.S.E. GmbH
|
|
# Copyright (c) 1998, 1999, 2000, 2001 SuSE GmbH
|
|
# Copyright (c) 2002 SuSE Linux AG
|
|
#
|
|
# Author: Frank Bodammer, Peter Poeml, Klaus Singvogel <feedback@suse.de>
|
|
#
|
|
# /etc/init.d/squid
|
|
# and its symbolic link
|
|
# /(usr/)sbin/rcsquid
|
|
#
|
|
### BEGIN INIT INFO
|
|
# Provides: squid
|
|
# Required-Start: $local_fs $remote_fs $network $time
|
|
# Should-Start: apache $named winbind
|
|
# Required-Stop: $local_fs $remote_fs $network $time
|
|
# Should-Stop: apache $named winbind
|
|
# Default-Start: 3 5
|
|
# Default-Stop: 0 1 2 6
|
|
# Short-Description: Squid web cache
|
|
# Description: Start the Squid web cache, providing
|
|
# HTTP, FTP and other proxy services
|
|
### END INIT INFO
|
|
#
|
|
# Note on runlevels:
|
|
# 0 - halt/poweroff 6 - reboot
|
|
# 1 - single user 2 - multiuser without network exported
|
|
# 3 - multiuser w/ network (text mode) 5 - multiuser w/ network and X11 (xdm)
|
|
|
|
|
|
# Check for missing binaries (stale symlinks should not happen)
|
|
# Note: Special treatment of stop for LSB conformance
|
|
SQUID_BIN=/usr/sbin/squid
|
|
test -x $SQUID_BIN || { echo "$SQUID_BIN not installed";
|
|
if [ "$1" = "stop" ]; then exit 0;
|
|
else exit 5; fi; }
|
|
|
|
# Check for existence of needed config file and read it
|
|
SQUID_SYSCONFIG=/etc/sysconfig/squid
|
|
test -r $SQUID_SYSCONFIG || { echo "$SQUID_SYSCONFIG not existing";
|
|
if [ "$1" = "stop" ]; then exit 0;
|
|
else exit 6; fi; }
|
|
|
|
# Read config
|
|
. $SQUID_SYSCONFIG
|
|
|
|
SQUID_PID=/var/run/squid.pid
|
|
SQUID_CONF=/etc/squid/squid.conf
|
|
SQUID_S_T=${SQUID_SHUTDOWN_TIMEOUT:="60"}
|
|
SQUID_OPTS=${SQUID_START_OPTIONS:="-sY"}
|
|
SQUID_ULIMIT=${SQUID_DEFAULT_ULIMT:="4096"}
|
|
|
|
# determine which one is the cache_swap directory
|
|
SQUID_CACHE_DIR=$(perl -n -e \
|
|
'/^cache_dir\s+\S+\s+(.*)\s+\d+\s+\d+\s+\d+/ && print "$1"' $SQUID_CONF)
|
|
|
|
ulimit -n "$SQUID_ULIMIT"
|
|
|
|
#IN: $SQUID_CACHE_DIR
|
|
setup_squid_cache_dir(){
|
|
for adir in "$1" ; do
|
|
if [ ! -d $adir/00 ]; then # create missing cache directories
|
|
umask 027 # prevent users reading any cache data
|
|
echo -n " ($adir)"
|
|
$SQUID_BIN -z -F > /dev/null 2>&1
|
|
fi
|
|
if [ ! -d $adir/00 ]; then
|
|
echo " - failed while creating cache_dir ! "
|
|
rc_failed
|
|
rc_status -v
|
|
rc_exit
|
|
fi
|
|
done
|
|
sleep 2
|
|
}
|
|
|
|
# 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 be verbose in local rc status and clear it afterwards
|
|
# rc_status -v -r ditto and clear both the local and overall rc status
|
|
# rc_status -s display "skipped" and exit with status 3
|
|
# rc_status -u display "unused" and exit with status 3
|
|
# rc_failed set local and overall rc status to failed
|
|
# rc_failed <num> set local and overall rc status to <num>
|
|
# rc_reset clear both the local and overall rc status
|
|
# rc_exit exit appropriate to overall rc status
|
|
# rc_active checks whether a service is activated by symlinks
|
|
. /etc/rc.status
|
|
|
|
# Reset status of this service
|
|
rc_reset
|
|
|
|
|
|
case "$1" in
|
|
start)
|
|
echo -n "Starting WWW-proxy squid "
|
|
if /sbin/checkproc $SQUID_BIN ; then
|
|
echo -n "- Warning: squid already running ! "
|
|
rc_failed
|
|
else
|
|
[ -e $SQUID_PID ] && echo -n "- Warning: $SQUID_PID exists ! "
|
|
if [ -n "$SQUID_CACHE_DIR" -a -d "$SQUID_CACHE_DIR" ]; then
|
|
setup_squid_cache_dir "$SQUID_CACHE_DIR"
|
|
fi
|
|
fi
|
|
startproc -l /var/log/squid/rcsquid.log $SQUID_BIN "$SQUID_OPTS"
|
|
|
|
# Remember status and be verbose
|
|
rc_status -v
|
|
;;
|
|
stop)
|
|
echo -n "Shutting down WWW-proxy squid "
|
|
if /sbin/checkproc $SQUID_BIN ; then
|
|
$SQUID_BIN -k shutdown
|
|
sleep 2
|
|
if [ -e $SQUID_PID ] ; then
|
|
echo -n "- wait a minute or two... "
|
|
i="$SQUID_S_T"
|
|
while [ -e $SQUID_PID ] && [ $i -gt 0 ] ; do
|
|
sleep 2
|
|
i=$[$i-1]
|
|
echo -n "."
|
|
[ $i -eq 41 ] && echo
|
|
done
|
|
fi
|
|
if /sbin/checkproc $SQUID_BIN ; then
|
|
killproc -TERM $SQUID_BIN
|
|
echo -n " Warning: squid killed !"
|
|
fi
|
|
else
|
|
echo -n "- Warning: squid not running ! "
|
|
rc_failed 7
|
|
fi
|
|
|
|
# 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)
|
|
$0 reload
|
|
|
|
# Remember status and be quiet
|
|
rc_status
|
|
;;
|
|
reload)
|
|
echo -n "Reloading WWW-proxy squid "
|
|
if /sbin/checkproc $SQUID_BIN ; then
|
|
$SQUID_BIN -k rotate
|
|
sleep 2
|
|
$SQUID_BIN -k reconfigure
|
|
rc_status
|
|
else
|
|
echo -n "- Warning: squid not running ! "
|
|
rc_failed 7
|
|
fi
|
|
|
|
# Remember status and be verbose
|
|
rc_status -v
|
|
;;
|
|
status)
|
|
echo -n "Checking for WWW-proxy squid "
|
|
## Check status with checkproc(8), if process is running
|
|
## checkproc will return with exit status 0.
|
|
|
|
# Return value is slightly different for the status command:
|
|
# 0 - service up and running
|
|
# 1 - service dead, but /var/run/ pid file exists
|
|
# 2 - service dead, but /var/lock/ lock file exists
|
|
# 3 - service not running (unused)
|
|
# 4 - service status unknown :-(
|
|
# 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.)
|
|
|
|
# NOTE: checkproc returns LSB compliant status values.
|
|
/sbin/checkproc $SQUID_BIN
|
|
|
|
# Remember status and be verbose
|
|
rc_status -v
|
|
;;
|
|
probe)
|
|
test $SQUID_CONF -nt $SQUID_PID && echo reload
|
|
;;
|
|
*)
|
|
echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
|
|
exit 1
|
|
;;
|
|
esac
|
|
rc_exit
|
|
|