|
Line 0
Link Here
|
|
|
1 |
#! /bin/sh |
| 2 |
@%@UCRWARNING=# @%@ |
| 3 |
# |
| 4 |
# squid3 Startup script for the SQUID HTTP proxy-cache. |
| 5 |
# |
| 6 |
# Version: @(#)squid3.rc 1.0 07-Jul-2006 luigi@debian.org |
| 7 |
# |
| 8 |
### BEGIN INIT INFO |
| 9 |
# Provides: squid3 |
| 10 |
# Required-Start: $network $remote_fs $syslog |
| 11 |
# Required-Stop: $network $remote_fs $syslog |
| 12 |
# Should-Start: $named |
| 13 |
# Should-Stop: $named |
| 14 |
# Default-Start: 2 3 4 5 |
| 15 |
# Default-Stop: 0 1 6 |
| 16 |
# Short-Description: Squid HTTP Proxy version 3.x |
| 17 |
### END INIT INFO |
| 18 |
|
| 19 |
NAME=squid3 |
| 20 |
DESC="Squid HTTP Proxy 3.x" |
| 21 |
DAEMON=/usr/sbin/squid3 |
| 22 |
PIDFILE=/var/run/$NAME.pid |
| 23 |
CONFIG=/etc/squid3/squid.conf |
| 24 |
SQUID_ARGS="-YC -f $CONFIG" |
| 25 |
|
| 26 |
[ ! -f /etc/default/squid3 ] || . /etc/default/squid3 |
| 27 |
|
| 28 |
. /lib/lsb/init-functions |
| 29 |
|
| 30 |
PATH=/bin:/usr/bin:/sbin:/usr/sbin |
| 31 |
|
| 32 |
[ -x $DAEMON ] || exit 0 |
| 33 |
|
| 34 |
ulimit -n 65535 |
| 35 |
|
| 36 |
find_cache_dir () { |
| 37 |
w=" " # space tab |
| 38 |
res=`sed -ne ' |
| 39 |
s/^'$1'['"$w"']\+[^'"$w"']\+['"$w"']\+\([^'"$w"']\+\).*$/\1/p; |
| 40 |
t end; |
| 41 |
d; |
| 42 |
:end q' < $CONFIG` |
| 43 |
[ -n "$res" ] || res=$2 |
| 44 |
echo "$res" |
| 45 |
} |
| 46 |
|
| 47 |
find_cache_type () { |
| 48 |
w=" " # space tab |
| 49 |
res=`sed -ne ' |
| 50 |
s/^'$1'['"$w"']\+\([^'"$w"']\+\).*$/\1/p; |
| 51 |
t end; |
| 52 |
d; |
| 53 |
:end q' < $CONFIG` |
| 54 |
[ -n "$res" ] || res=$2 |
| 55 |
echo "$res" |
| 56 |
} |
| 57 |
|
| 58 |
start () { |
| 59 |
cache_dir=`find_cache_dir cache_dir` |
| 60 |
cache_type=`find_cache_type cache_dir` |
| 61 |
|
| 62 |
# |
| 63 |
# Create spool dirs if they don't exist. |
| 64 |
# |
| 65 |
if [ "$cache_type" = "coss" -a -d "$cache_dir" -a ! -f "$cache_dir/stripe" ] || [ "$cache_type" != "coss" -a -d "$cache_dir" -a ! -d "$cache_dir/00" ] |
| 66 |
then |
| 67 |
log_warning_msg "Creating $DESC cache structure" |
| 68 |
$DAEMON -z -f $CONFIG |
| 69 |
fi |
| 70 |
|
| 71 |
umask 027 |
| 72 |
ulimit -n 65535 |
| 73 |
cd $cache_dir |
| 74 |
start-stop-daemon --quiet --start \ |
| 75 |
--pidfile $PIDFILE \ |
| 76 |
--exec $DAEMON -- $SQUID_ARGS < /dev/null |
| 77 |
return $? |
| 78 |
} |
| 79 |
|
| 80 |
stop () { |
| 81 |
PID=`cat $PIDFILE 2>/dev/null` |
| 82 |
start-stop-daemon --stop --quiet --pidfile $PIDFILE --exec $DAEMON |
| 83 |
# |
| 84 |
# Now we have to wait until squid has _really_ stopped. |
| 85 |
# |
| 86 |
sleep 2 |
| 87 |
if test -n "$PID" && kill -0 $PID 2>/dev/null |
| 88 |
then |
| 89 |
log_action_begin_msg " Waiting" |
| 90 |
cnt=0 |
| 91 |
while kill -0 $PID 2>/dev/null |
| 92 |
do |
| 93 |
cnt=`expr $cnt + 1` |
| 94 |
if [ $cnt -gt 24 ] |
| 95 |
then |
| 96 |
log_action_end_msg 1 |
| 97 |
return 1 |
| 98 |
fi |
| 99 |
sleep 5 |
| 100 |
log_action_cont_msg "" |
| 101 |
done |
| 102 |
log_action_end_msg 0 |
| 103 |
return 0 |
| 104 |
else |
| 105 |
return 0 |
| 106 |
fi |
| 107 |
} |
| 108 |
|
| 109 |
case "$1" in |
| 110 |
start) |
| 111 |
# check ucr autostart setting |
| 112 |
if [ -f "/usr/share/univention-config-registry/init-autostart.lib" ]; then |
| 113 |
. "/usr/share/univention-config-registry/init-autostart.lib" |
| 114 |
check_autostart univention-squid squid/autostart |
| 115 |
fi |
| 116 |
log_daemon_msg "Starting $DESC" "$NAME" |
| 117 |
if start ; then |
| 118 |
log_end_msg $? |
| 119 |
else |
| 120 |
log_end_msg $? |
| 121 |
fi |
| 122 |
;; |
| 123 |
stop) |
| 124 |
log_daemon_msg "Stopping $DESC" "$NAME" |
| 125 |
if stop ; then |
| 126 |
log_end_msg $? |
| 127 |
else |
| 128 |
log_end_msg $? |
| 129 |
fi |
| 130 |
;; |
| 131 |
reload|force-reload) |
| 132 |
log_action_msg "Reloading $DESC configuration files" |
| 133 |
start-stop-daemon --stop --signal 1 \ |
| 134 |
--pidfile $PIDFILE --quiet --exec $DAEMON |
| 135 |
log_action_end_msg 0 |
| 136 |
;; |
| 137 |
restart) |
| 138 |
log_daemon_msg "Restarting $DESC" "$NAME" |
| 139 |
stop |
| 140 |
if start ; then |
| 141 |
log_end_msg $? |
| 142 |
else |
| 143 |
log_end_msg $? |
| 144 |
fi |
| 145 |
;; |
| 146 |
status) |
| 147 |
status_of_proc -p $PIDFILE $DAEMON $NAME && exit 0 || exit 3 |
| 148 |
;; |
| 149 |
*) |
| 150 |
echo "Usage: /etc/init.d/$NAME {start|stop|reload|force-reload|restart|status}" |
| 151 |
exit 3 |
| 152 |
;; |
| 153 |
esac |
| 154 |
|
| 155 |
exit 0 |
| 156 |
|