1 |
mrness 09/10/25 08:35:47 |
2 |
|
3 |
Modified: squid.initd-logrotate squid.initd squid.confd |
4 |
Log: |
5 |
Add support for multiple instances of squid service (#287941). |
6 |
(Portage version: 2.1.6.13/cvs/Linux x86_64) |
7 |
|
8 |
Revision Changes Path |
9 |
1.10 net-proxy/squid/files/squid.initd-logrotate |
10 |
|
11 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/net-proxy/squid/files/squid.initd-logrotate?rev=1.10&view=markup |
12 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/net-proxy/squid/files/squid.initd-logrotate?rev=1.10&content-type=text/plain |
13 |
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/net-proxy/squid/files/squid.initd-logrotate?r1=1.9&r2=1.10 |
14 |
|
15 |
Index: squid.initd-logrotate |
16 |
=================================================================== |
17 |
RCS file: /var/cvsroot/gentoo-x86/net-proxy/squid/files/squid.initd-logrotate,v |
18 |
retrieving revision 1.9 |
19 |
retrieving revision 1.10 |
20 |
diff -u -r1.9 -r1.10 |
21 |
--- squid.initd-logrotate 16 Aug 2009 11:01:46 -0000 1.9 |
22 |
+++ squid.initd-logrotate 25 Oct 2009 08:35:46 -0000 1.10 |
23 |
@@ -1,11 +1,12 @@ |
24 |
#!/sbin/runscript |
25 |
# Copyright 1999-2006 Gentoo Foundation |
26 |
# Distributed under the terms of the GNU General Public License v2 |
27 |
-# $Header: /var/cvsroot/gentoo-x86/net-proxy/squid/files/squid.initd-logrotate,v 1.9 2009/08/16 11:01:46 mrness Exp $ |
28 |
+# $Header: /var/cvsroot/gentoo-x86/net-proxy/squid/files/squid.initd-logrotate,v 1.10 2009/10/25 08:35:46 mrness Exp $ |
29 |
|
30 |
opts="${opts} reload" |
31 |
|
32 |
depend() { |
33 |
+ use dns |
34 |
need net |
35 |
} |
36 |
|
37 |
@@ -29,24 +30,47 @@ |
38 |
} |
39 |
|
40 |
checkconfig() { |
41 |
+ if [ ! -f /etc/squid/${SVCNAME}.conf ]; then |
42 |
+ eerror "You need to create /etc/squid/${SVCNAME}.conf first." |
43 |
+ eerror "An example can be found in /etc/squid/squid.conf.default" |
44 |
+ return 1 |
45 |
+ fi |
46 |
+ |
47 |
+ local PIDFILE=$(awk '/^[ \t]*pid_filename[ \t]+/ { print $2 }' < /etc/squid/${SVCNAME}.conf) |
48 |
+ [ -z ${PIDFILE} ] && PIDFILE=/var/run/squid.pid |
49 |
+ if [ /var/run/${SVCNAME}.pid != ${PIDFILE} ]; then |
50 |
+ eerror "/etc/squid/${SVCNAME}.conf must set pid_filename to" |
51 |
+ eerror " /var/run/${SVCNAME}.pid" |
52 |
+ eerror "CAUTION: http_port, cache_dir and *_log parameters must be different than" |
53 |
+ eerror " in any other instance of squid." |
54 |
+ return 1 |
55 |
+ fi |
56 |
+ |
57 |
maxfds |
58 |
- |
59 |
- local CACHE_SWAP=$(awk '/^[ \t]*cache_dir[ \t]+/ { if ($2 == "coss" ) printf "%s/stripe ", $3 ; else printf "%s/00 ", $3; }' < /etc/squid/squid.conf) |
60 |
+ |
61 |
+ local CACHE_SWAP=$(awk '/^[ \t]*cache_dir[ \t]+/ { if ($2 == "coss" ) printf "%s/stripe ", $3 ; else printf "%s/00 ", $3; }' < /etc/squid/${SVCNAME}.conf) |
62 |
[ -z "$CACHE_SWAP" ] && CACHE_SWAP="/var/cache/squid/00" |
63 |
|
64 |
local x |
65 |
for x in $CACHE_SWAP ; do |
66 |
if [ ! -e $x ] ; then |
67 |
- ebegin "Initializing cache directories" |
68 |
+ ebegin "Initializing cache directory ${x%/*}" |
69 |
local ORIG_UMASK=$(umask) |
70 |
umask 027 |
71 |
- local INIT_CACHE_RESPONSE="$(/usr/sbin/squid -z -N -D 2>&1)" |
72 |
+ |
73 |
+ if ! (mkdir -p ${x%/*} && chown squid ${x%/*}) ; then |
74 |
+ eend 1 |
75 |
+ return 1 |
76 |
+ fi |
77 |
+ |
78 |
+ local INIT_CACHE_RESPONSE="$(/usr/sbin/squid -z -N -f /etc/squid/${SVCNAME}.conf 2>&1)" |
79 |
if [ $? != 0 ] || echo "$INIT_CACHE_RESPONSE" | grep -q "erminated abnormally" ; then |
80 |
umask $ORIG_UMASK |
81 |
eend 1 |
82 |
echo "$INIT_CACHE_RESPONSE" |
83 |
return 1 |
84 |
fi |
85 |
+ |
86 |
umask $ORIG_UMASK |
87 |
eend 0 |
88 |
break |
89 |
@@ -58,20 +82,20 @@ |
90 |
|
91 |
start() { |
92 |
checkconfig || return 1 |
93 |
- ebegin "Starting squid" |
94 |
- KRB5_KTNAME="${SQUID_KEYTAB}" /usr/sbin/squid ${SQUID_OPTS} |
95 |
+ ebegin "Starting ${SVCNAME}" |
96 |
+ KRB5_KTNAME="${SQUID_KEYTAB}" /usr/sbin/squid ${SQUID_OPTS} -f /etc/squid/${SVCNAME}.conf |
97 |
eend $? && sleep 1 |
98 |
} |
99 |
|
100 |
stop() { |
101 |
- ebegin "Stopping squid" |
102 |
- /usr/sbin/squid -k shutdown |
103 |
+ ebegin "Stopping ${SVCNAME}" |
104 |
+ /usr/sbin/squid -k shutdown -f /etc/squid/${SVCNAME}.conf |
105 |
# Now we have to wait until squid has _really_ stopped. |
106 |
sleep 1 |
107 |
- if [ -f /var/run/squid.pid ] ; then |
108 |
+ if [ -f /var/run/${SVCNAME}.pid ] ; then |
109 |
einfon "Waiting for squid to shutdown ." |
110 |
cnt=0 |
111 |
- while [ -f /var/run/squid.pid ] ; do |
112 |
+ while [ -f /var/run/${SVCNAME}.pid ] ; do |
113 |
cnt=$(expr $cnt + 1) |
114 |
if [ $cnt -gt 60 ] ; then |
115 |
# Waited 120 seconds now. Fail. |
116 |
@@ -89,7 +113,7 @@ |
117 |
|
118 |
reload() { |
119 |
checkconfig || return 1 |
120 |
- ebegin "Reloading squid" |
121 |
- /usr/sbin/squid -k reconfigure |
122 |
+ ebegin "Reloading ${SVCNAME}" |
123 |
+ /usr/sbin/squid -k reconfigure -f /etc/squid/${SVCNAME}.conf |
124 |
eend $? |
125 |
} |
126 |
|
127 |
|
128 |
|
129 |
1.12 net-proxy/squid/files/squid.initd |
130 |
|
131 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/net-proxy/squid/files/squid.initd?rev=1.12&view=markup |
132 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/net-proxy/squid/files/squid.initd?rev=1.12&content-type=text/plain |
133 |
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/net-proxy/squid/files/squid.initd?r1=1.11&r2=1.12 |
134 |
|
135 |
Index: squid.initd |
136 |
=================================================================== |
137 |
RCS file: /var/cvsroot/gentoo-x86/net-proxy/squid/files/squid.initd,v |
138 |
retrieving revision 1.11 |
139 |
retrieving revision 1.12 |
140 |
diff -u -r1.11 -r1.12 |
141 |
--- squid.initd 16 Aug 2009 11:01:46 -0000 1.11 |
142 |
+++ squid.initd 25 Oct 2009 08:35:46 -0000 1.12 |
143 |
@@ -1,11 +1,12 @@ |
144 |
#!/sbin/runscript |
145 |
# Copyright 1999-2006 Gentoo Foundation |
146 |
# Distributed under the terms of the GNU General Public License v2 |
147 |
-# $Header: /var/cvsroot/gentoo-x86/net-proxy/squid/files/squid.initd,v 1.11 2009/08/16 11:01:46 mrness Exp $ |
148 |
+# $Header: /var/cvsroot/gentoo-x86/net-proxy/squid/files/squid.initd,v 1.12 2009/10/25 08:35:46 mrness Exp $ |
149 |
|
150 |
opts="${opts} reload rotate" |
151 |
|
152 |
depend() { |
153 |
+ use dns |
154 |
need net |
155 |
} |
156 |
|
157 |
@@ -29,24 +30,47 @@ |
158 |
} |
159 |
|
160 |
checkconfig() { |
161 |
+ if [ ! -f /etc/squid/${SVCNAME}.conf ]; then |
162 |
+ eerror "You need to create /etc/squid/${SVCNAME}.conf first." |
163 |
+ eerror "An example can be found in /etc/squid/squid.conf.default" |
164 |
+ return 1 |
165 |
+ fi |
166 |
+ |
167 |
+ local PIDFILE=$(awk '/^[ \t]*pid_filename[ \t]+/ { print $2 }' < /etc/squid/${SVCNAME}.conf) |
168 |
+ [ -z ${PIDFILE} ] && PIDFILE=/var/run/squid.pid |
169 |
+ if [ /var/run/${SVCNAME}.pid != ${PIDFILE} ]; then |
170 |
+ eerror "/etc/squid/${SVCNAME}.conf must set pid_filename to" |
171 |
+ eerror " /var/run/${SVCNAME}.pid" |
172 |
+ eerror "CAUTION: http_port, cache_dir and *_log parameters must be different than" |
173 |
+ eerror " in any other instance of squid." |
174 |
+ return 1 |
175 |
+ fi |
176 |
+ |
177 |
maxfds |
178 |
- |
179 |
- local CACHE_SWAP=$(awk '/^[ \t]*cache_dir[ \t]+/ { if ($2 == "coss" ) printf "%s/stripe ", $3 ; else printf "%s/00 ", $3; }' < /etc/squid/squid.conf) |
180 |
+ |
181 |
+ local CACHE_SWAP=$(awk '/^[ \t]*cache_dir[ \t]+/ { if ($2 == "coss" ) printf "%s/stripe ", $3 ; else printf "%s/00 ", $3; }' < /etc/squid/${SVCNAME}.conf) |
182 |
[ -z "$CACHE_SWAP" ] && CACHE_SWAP="/var/cache/squid/00" |
183 |
|
184 |
local x |
185 |
for x in $CACHE_SWAP ; do |
186 |
if [ ! -e $x ] ; then |
187 |
- ebegin "Initializing cache directories" |
188 |
+ ebegin "Initializing cache directory ${x%/*}" |
189 |
local ORIG_UMASK=$(umask) |
190 |
umask 027 |
191 |
- local INIT_CACHE_RESPONSE="$(/usr/sbin/squid -z -N -D 2>&1)" |
192 |
+ |
193 |
+ if ! (mkdir -p ${x%/*} && chown squid ${x%/*}) ; then |
194 |
+ eend 1 |
195 |
+ return 1 |
196 |
+ fi |
197 |
+ |
198 |
+ local INIT_CACHE_RESPONSE="$(/usr/sbin/squid -z -N -f /etc/squid/${SVCNAME}.conf 2>&1)" |
199 |
if [ $? != 0 ] || echo "$INIT_CACHE_RESPONSE" | grep -q "erminated abnormally" ; then |
200 |
umask $ORIG_UMASK |
201 |
eend 1 |
202 |
echo "$INIT_CACHE_RESPONSE" |
203 |
return 1 |
204 |
fi |
205 |
+ |
206 |
umask $ORIG_UMASK |
207 |
eend 0 |
208 |
break |
209 |
@@ -58,20 +82,20 @@ |
210 |
|
211 |
start() { |
212 |
checkconfig || return 1 |
213 |
- ebegin "Starting squid" |
214 |
- KRB5_KTNAME="${SQUID_KEYTAB}" /usr/sbin/squid ${SQUID_OPTS} |
215 |
+ ebegin "Starting ${SVCNAME}" |
216 |
+ KRB5_KTNAME="${SQUID_KEYTAB}" /usr/sbin/squid ${SQUID_OPTS} -f /etc/squid/${SVCNAME}.conf |
217 |
eend $? && sleep 1 |
218 |
} |
219 |
|
220 |
stop() { |
221 |
- ebegin "Stopping squid" |
222 |
- /usr/sbin/squid -k shutdown |
223 |
+ ebegin "Stopping ${SVCNAME}" |
224 |
+ /usr/sbin/squid -k shutdown -f /etc/squid/${SVCNAME}.conf |
225 |
# Now we have to wait until squid has _really_ stopped. |
226 |
sleep 1 |
227 |
- if [ -f /var/run/squid.pid ] ; then |
228 |
+ if [ -f /var/run/${SVCNAME}.pid ] ; then |
229 |
einfon "Waiting for squid to shutdown ." |
230 |
cnt=0 |
231 |
- while [ -f /var/run/squid.pid ] ; do |
232 |
+ while [ -f /var/run/${SVCNAME}.pid ] ; do |
233 |
cnt=$(expr $cnt + 1) |
234 |
if [ $cnt -gt 60 ] ; then |
235 |
# Waited 120 seconds now. Fail. |
236 |
@@ -89,14 +113,14 @@ |
237 |
|
238 |
reload() { |
239 |
checkconfig || return 1 |
240 |
- ebegin "Reloading squid" |
241 |
- /usr/sbin/squid -k reconfigure |
242 |
+ ebegin "Reloading ${SVCNAME}" |
243 |
+ /usr/sbin/squid -k reconfigure -f /etc/squid/${SVCNAME}.conf |
244 |
eend $? |
245 |
} |
246 |
|
247 |
rotate() { |
248 |
- service_started squid || return 1 |
249 |
- ebegin "Rotating logs" |
250 |
- /usr/sbin/squid -k rotate |
251 |
+ service_started ${SVCNAME} || return 1 |
252 |
+ ebegin "Rotating ${SVCNAME} logs" |
253 |
+ /usr/sbin/squid -k rotate -f /etc/squid/${SVCNAME}.conf |
254 |
eend $? |
255 |
} |
256 |
|
257 |
|
258 |
|
259 |
1.3 net-proxy/squid/files/squid.confd |
260 |
|
261 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/net-proxy/squid/files/squid.confd?rev=1.3&view=markup |
262 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/net-proxy/squid/files/squid.confd?rev=1.3&content-type=text/plain |
263 |
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/net-proxy/squid/files/squid.confd?r1=1.2&r2=1.3 |
264 |
|
265 |
Index: squid.confd |
266 |
=================================================================== |
267 |
RCS file: /var/cvsroot/gentoo-x86/net-proxy/squid/files/squid.confd,v |
268 |
retrieving revision 1.2 |
269 |
retrieving revision 1.3 |
270 |
diff -u -r1.2 -r1.3 |
271 |
--- squid.confd 30 Nov 2008 19:20:44 -0000 1.2 |
272 |
+++ squid.confd 25 Oct 2009 08:35:46 -0000 1.3 |
273 |
@@ -1,10 +1,10 @@ |
274 |
# Copyright 1999-2004 Gentoo Foundation |
275 |
# Distributed under the terms of the GNU General Public License v2 |
276 |
-# $Header: /var/cvsroot/gentoo-x86/net-proxy/squid/files/squid.confd,v 1.2 2008/11/30 19:20:44 mrness Exp $ |
277 |
+# $Header: /var/cvsroot/gentoo-x86/net-proxy/squid/files/squid.confd,v 1.3 2009/10/25 08:35:46 mrness Exp $ |
278 |
|
279 |
# Config file for /etc/init.d/squid |
280 |
|
281 |
-SQUID_OPTS="-DYC" |
282 |
+SQUID_OPTS="-YC" |
283 |
|
284 |
# Max. number of filedescriptors to use. You can increase this on a busy |
285 |
# cache to a maximum of (currently) 8192 filedescriptors. Default is 1024. |