]> git.pld-linux.org Git - packages/squid.git/blob - squid.init
- rewrited with new functions
[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 25
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 #
16 # pidfile:      /var/run/squid.pid
17 # config:       /etc/squid/squid.conf
18
19
20 # Source function library
21 . /etc/rc.d/init.d/functions
22
23 # Get network config
24 . /etc/sysconfig/network
25
26 # Get service config
27 [ -f /etc/sysconfig/squid ] && . /etc/sysconfig/squid
28
29 # Check that networking is up.
30 if is_no "${NETWORKING}"; then
31         msg_Network_Down Squid
32         exit 1
33 fi
34
35 # Sanity check
36 [ -f /etc/squid/squid.conf ] || exit 0
37
38 # See how we were called.
39 case "$1" in
40   start)
41         # Check if the service is already running?
42         if [ ! -f /var/lock/subsys/squid ]; then
43                 show "Prepare squid cache"
44                 busy
45                 if [ ! -d $CACHE_SWAP/00 ]; then
46                         squid -z -F &>/dev/null
47                 fi
48                 deltext;ok
49
50                 msg_starting Squid
51                 busy            
52                 squid -N $SQUID_OPTS &
53                 if ps -C squid >/dev/null 2>&1; then
54                     deltext;ok
55                 else
56                     deltext;fail
57                 fi
58                 RETVAL=$?
59                 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/squid
60         else
61             msg_Already_Running Squid
62         fi
63         ;;
64   stop)
65         # Stop daemons.
66         if [ -f /var/lock/subsys/squid ]; then
67                 msg_stopping squid
68                 killproc squid
69                 rm -f /var/lock/subsys/squid >/dev/null 2>&1
70         else
71                 msg_Not_Running squid
72                 exit 1
73         fi
74         ;;
75   restart)
76         $0 stop
77         $0 start
78         ;;
79   status)
80         status squid
81         exit $?
82         ;;
83   *)
84         msg_Usage "$0 {start|stop|status|restart}"
85         exit 1
86 esac
87
88 exit $RETVAL
This page took 0.106873 seconds and 4 git commands to generate.