aboutsummaryrefslogtreecommitdiffstats
path: root/main/squid/squid.initd
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2009-09-01 13:12:42 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2009-09-01 13:12:42 +0000
commit5d4692319f2ccb4e39b50808e89e765e4c0f980e (patch)
tree83a0ac2feecd82ea38fc4c0abc0b17297c30c127 /main/squid/squid.initd
parent353ecc79dae24a45ab45b41e4c79caa646aeee99 (diff)
downloadaports-5d4692319f2ccb4e39b50808e89e765e4c0f980e.tar.bz2
aports-5d4692319f2ccb4e39b50808e89e765e4c0f980e.tar.xz
main/squid: fix for squid initscript and pidfile
fixes #133
Diffstat (limited to 'main/squid/squid.initd')
-rw-r--r--main/squid/squid.initd26
1 files changed, 19 insertions, 7 deletions
diff --git a/main/squid/squid.initd b/main/squid/squid.initd
index bbdc2bed2a..4242b216ec 100644
--- a/main/squid/squid.initd
+++ b/main/squid/squid.initd
@@ -5,6 +5,8 @@
opts="${opts} reload rotate"
+conf=/etc/squid/squid.conf
+
depend() {
need net
}
@@ -25,7 +27,7 @@ maxfds() {
checkconfig() {
maxfds
- local CACHE_SWAP=$(awk '/^[ \t]*cache_dir[ \t]+/ { if ($2 == "coss" ) printf "%s/stripe ", $3 ; else printf "%s/00 ", $3; }' < /etc/squid/squid.conf)
+ local CACHE_SWAP=$(awk '/^[ \t]*cache_dir[ \t]+/ { if ($2 == "coss" ) printf "%s/stripe ", $3 ; else printf "%s/00 ", $3; }' < $conf)
[ -z "$CACHE_SWAP" ] && CACHE_SWAP="/var/cache/squid/00"
local x
@@ -50,27 +52,37 @@ checkconfig() {
return 0
}
+get_pidfile() {
+ PIDFILE=$(awk '/^[ \t]*pid_filename[ \t]+/ {print $2}' $conf)
+ [ -z "$PIDFILE" ] && PIDFILE=/var/run/squid/squid.pid
+}
+
start() {
+ get_pidfile
checkconfig || return 1
ebegin "Starting squid"
- KRB5_KTNAME="${SQUID_KEYTAB}" /usr/sbin/squid ${SQUID_OPTS}
+ start-stop-daemon --start --pidfile "$PIDFILE" \
+ --env KRB5_KTNAME="${SQUID_KEYTAB}" \
+ --exec /usr/sbin/squid -- ${SQUID_OPTS}
eend $? && sleep 1
}
stop() {
+ local rc=0
ebegin "Stopping squid"
+ get_pidfile
/usr/sbin/squid -k shutdown
+
# Now we have to wait until squid has _really_ stopped.
- sleep 1
- if [ -f /var/run/squid.pid ] ; then
+ if [ -f "$PIDFILE" ] ; then
einfon "Waiting for squid to shutdown ."
cnt=0
- while [ -f /var/run/squid.pid ] ; do
+ while [ -f "$PIDFILE" ] ; do
cnt=$(expr $cnt + 1)
if [ $cnt -gt 60 ] ; then
# Waited 120 seconds now. Fail.
echo
- eend 1 "Failed."
+ rc=1
break
fi
sleep 2
@@ -78,7 +90,7 @@ stop() {
done
echo
fi
- eend 0
+ eend $rc
}
reload() {