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