]> git.pld-linux.org Git - packages/squid.git/blob - squid.init
- functins, force-reload should be same as restart as i understand it
[packages/squid.git] / squid.init
1 #!/bin/sh
2 #
3 # squid         This shell script takes care of starting and stopping
4 #               Squid Internet Object Cache
5 #
6 # chkconfig:    345 90 10
7 #
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 \
14 #               consumption.
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 \
22 #               comunicación.
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.
30 #
31 # pidfile:      /var/run/squid.pid
32 # config:       /etc/squid/squid.conf
33
34
35 # Source function library
36 . /etc/rc.d/init.d/functions
37
38 # Get network config
39 . /etc/sysconfig/network
40
41 # Get service config
42 [ -f /etc/sysconfig/squid ] && . /etc/sysconfig/squid
43
44 # Set default shutdown timeout if it is not set in service config
45 SQUID_SHUTDOWN_TIMEOUT=${SQUID_SHUTDOWN_TIMEOUT:-60}
46
47 # Check that networking is up.
48 if is_yes "${NETWORKING}"; then
49         if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status -a "$1" != init ]; then
50                 msg_network_down Squid
51                 exit 1
52         fi
53 else
54         exit 0
55 fi
56
57 start() {
58         # Check if the service is already running?
59         if [ ! -f /var/lock/subsys/squid ]; then
60                 msg_starting Squid
61                 daemon squid $SQUID_OPTS
62                 RETVAL=$?
63                 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/squid
64         else
65                 msg_already_running Squid
66         fi
67 }
68
69 stop() {
70         if [ -f /var/lock/subsys/squid ]; then
71                 # Stop daemons.
72                 msg_stopping Squid
73                 if [ -f /var/run/squid.pid ]; then
74                         PID=$(filter_chroot `cat /var/run/squid.pid`)
75                         if [ -z "$PID" ]; then
76                                 PID=0
77                         fi
78                 else
79                         PID=0
80                 fi
81                 killproc squid
82                 RETVAL=$?
83                 if [ ! $PID -eq 0 ]; then
84                         show "Waiting for Squid to stop"
85                         busy
86                         timeout=0
87                         while ps -U squid -o user | grep -q ^squid
88                         do
89                                 if [ $timeout -ge $SQUID_SHUTDOWN_TIMEOUT ]; then
90                                     break
91                                 fi
92                                 sleep 1
93                                 timeout=$((timeout+1))
94                         done
95                         ok
96                 fi
97                 rm -f /var/lock/subsys/squid >/dev/null 2>&1
98         else
99                 msg_not_running Squid
100         fi
101 }
102
103 reload() {
104         if [ -f /var/lock/subsys/squid ]; then
105                 msg_reloading Squid
106                 busy
107                 squid -k reconfigure
108                 RETVAL=$?
109                 [ $RETVAL -ne 0 ] && RETVAL=7
110                 [ $RETVAL -eq 0 ] && ok || fail
111         else
112                 msg_not_running Squid >&2
113                 exit 7
114         fi
115 }
116
117 RETVAL=0
118 # See how we were called.
119 case "$1" in
120   start)
121         start
122         ;;
123   stop)
124         stop
125         ;;
126   restart|force-reload)
127         stop
128         start
129         ;;
130   reload)
131         reload
132         ;;
133   status)
134         status squid
135         exit $?
136         ;;
137   init)
138         nls "Initializing %s" squid
139         squid -z
140         ;;
141   *)
142         msg_usage "$0 {start|stop|init|restart|reload|force-reload|status}"
143         exit 3
144 esac
145
146 exit $RETVAL
This page took 0.039402 seconds and 3 git commands to generate.