]> git.ipfire.org Git - thirdparty/squid.git/blame - contrib/squid.rc
SRV4 install fixes from Markus Gyger
[thirdparty/squid.git] / contrib / squid.rc
CommitLineData
e550e8b6 1#!/sbin/sh
2
3# Squid Internet Object Cache startup
4# AUTHOR: Markus Gyger
5# This is squid's startup file /sbin/init.d/squid or /etc/init.d/squid
6
7
8PATH=/opt/squid/bin:/usr/sbin:/usr/bin:/sbin:/bin
9export PATH
10
11
12config()
13{
14 # SGI IRIX 6.2
15 if [ -f /sbin/chkconfig ]
16 then if /sbin/chkconfig squid
17 then if [ -f /var/config/squid.options ]
18 then . /var/config/squid.options
19 fi
20 SQUID=1
21 else SQUID=0
22 fi
23
24 # Digital UNIX
25 elif [ -f /usr/sbin/rcmgr ]
26 then SQUID=`/usr/sbin/rcmgr get SQUID 0`
27 SQUID_OPTIONS=`/usr/sbin/rcmgr get SQUID_OPTIONS "-s"`
28 SQUID_RESPAWN=`/usr/sbin/rcmgr get SQUID_RESPAWN 1`
29
30 # HP-UX 10 / Linux
31 elif [ -f /etc/rc.config ]
32 then . /etc/rc.config
33
34 # SUN Solaris 2
35 else SQUID=1
36 SQUID_OPTIONS="-s"
37 SQUID_RESPAWN=1
38 fi
39
40 [ 1 = "${SQUID-}" ]
41}
42
43
44respawn()
45{
46 trap "" 1
47 fails=0
48 while [ $fails -le 5 ]
49 do start=`date +%d%H%M%S`
50 if "$@"
51 then logger -t "$1" -p local4.notice \
52 "respawn[$$]: Exiting due to shutdown"
53 return 0
54 fi
55 stop=`date +%d%H%M%S`
56 time=`expr $stop - $start`
57 [ "$time" -gt 10 ] && fails=0
58 fails=`expr $fails + 1`
59 done
60
61 logger -t "$1" -p local4.alert \
62 "respawn[$$]: Exiting due to repeated, frequent failures"
63 return 1
64}
65
66
67case $* in
68start_msg)
69 echo "Start Squid Internet Object Cache"
70 ;;
71
72stop_msg)
73 echo "Stopping Squid Internet Object Cache"
74 ;;
75
76start)
77 config || exit 2 # Squid not enabled
78
79 if whence=`type squid 2>&1`
80 then trap "" 1
81 if [ 0 = "${SQUID_RESPAWN-}" ]
82 then squid ${SQUID_OPTIONS-} &
83 else respawn squid ${SQUID_OPTIONS-} &
84 fi
85
86 else echo "ERROR: $whence" >&2
87 exit 1
88 fi
89 ;;
90
91stop)
92 config || exit 2 # Squid not enabled
93
94 squid ${SQUID_OPTIONS-} -k shutdown || exit 1
95 ;;
96
97reconf*|rotate|int*|debug|check|kill)
98 config
99
100 squid ${SQUID_OPTIONS-} -k "$1"
101 ;;
102
103*)
104 echo "usage: $0 {start|stop|reconfigure|rotate|interrupt|debug|check|kill}" >&2
105 echo " start start squid" >&2
106 echo " stop clean shutdown" >&2
107 echo " reconfigure reread configuration files" >&2
108 echo " rotate rotate log files" >&2
109 echo " interrupt quick clean shutdown " >&2
110 echo " debug toggle debug logging" >&2
111 echo " check check for running squid" >&2
112 echo " kill terminate squid by brute force" >&2
113
114 exit 1
115 ;;
116esac
117
118[ $? -eq 0 ] # only 0 and 1 exit values allowed
119exit