SOURCES: squid.init - check config before restart
glen
glen at pld-linux.org
Fri Nov 23 13:20:43 CET 2007
Author: glen Date: Fri Nov 23 12:20:43 2007 GMT
Module: SOURCES Tag: HEAD
---- Log message:
- check config before restart
---- Files affected:
SOURCES:
squid.init (1.46 -> 1.47)
---- Diffs:
================================================================
Index: SOURCES/squid.init
diff -u SOURCES/squid.init:1.46 SOURCES/squid.init:1.47
--- SOURCES/squid.init:1.46 Fri Nov 23 13:07:00 2007
+++ SOURCES/squid.init Fri Nov 23 13:20:38 2007
@@ -41,9 +41,6 @@
# Get service config
[ -f /etc/sysconfig/squid ] && . /etc/sysconfig/squid
-# Set default shutdown timeout if it is not set in service config
-SQUID_SHUTDOWN_TIMEOUT=${SQUID_SHUTDOWN_TIMEOUT:-60}
-
# Check that networking is up.
if is_yes "${NETWORKING}"; then
if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status -a "$1" != init ]; then
@@ -54,6 +51,13 @@
exit 0
fi
+# Set default shutdown timeout if it is not set in service config
+SQUID_SHUTDOWN_TIMEOUT=${SQUID_SHUTDOWN_TIMEOUT:-60}
+
+# determine which one is the cache_swap directory
+CACHE_SWAP=$(awk '/^cache_dir/{print $3}' /etc/squid/squid.conf)
+[ -z "$CACHE_SWAP" ] && CACHE_SWAP=/var/cache/squid
+
start() {
# Check if the service is already running?
if [ ! -f /var/lock/subsys/squid ]; then
@@ -71,7 +75,7 @@
# Stop daemons.
msg_stopping Squid
if [ -f /var/run/squid.pid ]; then
- PID=$(filter_chroot `cat /var/run/squid.pid`)
+ PID=$(filter_chroot $(cat /var/run/squid.pid))
if [ -z "$PID" ]; then
PID=0
fi
@@ -80,7 +84,7 @@
fi
killproc squid
RETVAL=$?
- if [ ! $PID -eq 0 ]; then
+ if [ $PID != 0 ]; then
show "Waiting for Squid to stop"
busy
timeout=0
@@ -90,7 +94,7 @@
break
fi
sleep 1
- timeout=$((timeout+1))
+ timeout=$((timeout + 1))
done
ok
fi
@@ -100,6 +104,15 @@
fi
}
+# check that squid config is ok
+# NOTE: needs running squid
+configtest() {
+ show "Checking squid config syntax"
+ squid -k check
+ RETVAL=$?
+ [ $RETVAL = 0 ] && ok || fail
+}
+
reload() {
if [ -f /var/lock/subsys/squid ]; then
msg_reloading Squid
@@ -109,11 +122,23 @@
[ $RETVAL -ne 0 ] && RETVAL=7
[ $RETVAL -eq 0 ] && ok || fail
else
- msg_not_running Squid >&2
+ msg_not_running Squid
exit 7
fi
}
+restart() {
+ # if service is up, do configtest
+ if [ -f /var/lock/subsys/squid ]; then
+ configtest
+ if [ $RETVAL != 0 ]; then
+ exit 1
+ fi
+ fi
+ stop
+ start
+}
+
RETVAL=0
# See how we were called.
case "$1" in
@@ -124,8 +149,7 @@
stop
;;
restart|force-reload)
- stop
- start
+ restart
;;
reload)
reload
================================================================
---- CVS-web:
http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/SOURCES/squid.init?r1=1.46&r2=1.47&f=u
More information about the pld-cvs-commit
mailing list