3 # squid This shell script takes care of starting and stopping
4 # Squid Internet Object Cache
8 # description: Squid - Internet Object Cache. Internet object caching is \
9 # a way to store requested Internet objects (i.e., data \
10 # available via the HTTP, FTP, and gopher protocols) on a \
11 # system closer to the requesting site than to the source. \
12 # Web browsers can then use the local Squid cache as a proxy \
13 # HTTP server, reducing access time as well as bandwidth \
15 # description(es): Squid - Cache de Objetos de Internet. Cache de objetos \
16 # es una manera de almacenar objetos Internet (i.e. Datos \
17 # disponibles vía protocolos HTTP, FTP y gopher) en un \
18 # sistema más próximo al site solicitador que el sistema \
19 # original en internet. Navegadores www pueden usar el \
20 # cache squid local como un servidor proxy HTTP, reduciendo \
21 # tanto el tiempo de acceso así como el consumo de banda de \
23 # description(pt_BR): Squid - Cache de Objetos da Internet. Cache de objetos \
24 # é uma maneira de armazenar objetos Internet (i.e. dados \
25 # disponíveis via protocolos HTTP, FTP e gopher) em um \
26 # sistema mais próximo ao site requisitante do que o sistema \
27 # original na internet. Navegadores www podem usar o cache \
28 # squid local como um servidor proxy HTTP, reduzindo o tempo \
29 # de acesso bem como o consumo de banda de comunicação.
31 # pidfile: /var/run/squid.pid
32 # config: /etc/squid/squid.conf
35 # Source function library
36 . /etc/rc.d/init.d/functions
39 . /etc/sysconfig/network
42 [ -f /etc/sysconfig/squid ] && . /etc/sysconfig/squid
44 # Check that networking is up.
45 if is_yes "${NETWORKING}"; then
46 if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status -a "$1" != init ]; then
47 msg_network_down Squid
54 # Set default shutdown timeout if it is not set in service config
55 SQUID_SHUTDOWN_TIMEOUT=${SQUID_SHUTDOWN_TIMEOUT:-60}
57 # determine which one is the cache_swap directory
58 CACHE_SWAP=$(awk '/^cache_dir/{print $3}' /etc/squid/squid.conf)
59 [ -z "$CACHE_SWAP" ] && CACHE_SWAP=/var/cache/squid
63 for dir in $CACHE_SWAP; do
64 if [ ! -d $dir/00 ]; then
68 if [ $need_init = 1 ]; then
69 show "Initializing Squid cache dirs"
70 squid -z -F -D >> /var/log/squid/squid.out 2>&1 && ok || fail
75 # Check if the service is already running?
76 if [ ! -f /var/lock/subsys/squid ]; then
79 daemon squid $SQUID_OPTS
81 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/squid
83 msg_already_running Squid
88 if [ -f /var/lock/subsys/squid ]; then
93 if [ -f /var/run/squid.pid ]; then
94 show "Waiting for Squid to stop"
99 [ ! -f /var/run/squid.pid ] || break
100 if [ $timeout -ge $SQUID_SHUTDOWN_TIMEOUT ]; then
104 sleep 1 && echo -n "."
105 timeout=$((timeout+1))
110 rm -f /var/lock/subsys/squid >/dev/null 2>&1
112 msg_not_running Squid
116 # check that squid config is ok
117 # NOTE: needs running squid
119 show "Checking squid config syntax"
120 squid -k check >> /var/log/squid/squid.out 2>&1
122 [ $RETVAL = 0 ] && ok || fail
126 if [ -f /var/lock/subsys/squid ]; then
131 [ $RETVAL -ne 0 ] && RETVAL=7
132 [ $RETVAL -eq 0 ] && ok || fail
134 msg_not_running Squid
140 # if service is up, do configtest
141 if [ -f /var/lock/subsys/squid ]; then
143 if [ $RETVAL != 0 ]; then
152 # if service is up, do configtest
153 if [ -f /var/lock/subsys/squid ]; then
155 if [ $RETVAL != 0 ]; then
166 # See how we were called.
188 show "Initializing Squid"; echo
192 msg_usage "$0 {start|stop|init|restart|try-restart|reload|force-reload|status}"