# 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
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
# 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
fi
killproc squid
RETVAL=$?
- if [ ! $PID -eq 0 ]; then
+ if [ $PID != 0 ]; then
show "Waiting for Squid to stop"
busy
timeout=0
break
fi
sleep 1
- timeout=$((timeout+1))
+ timeout=$((timeout + 1))
done
ok
fi
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
[ $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
stop
;;
restart|force-reload)
- stop
- start
+ restart
;;
reload)
reload