SOURCES: squid.init - make cache dirs automatically

glen glen at pld-linux.org
Fri Nov 23 13:44:48 CET 2007


Author: glen                         Date: Fri Nov 23 12:44:48 2007 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- make cache dirs automatically

---- Files affected:
SOURCES:
   squid.init (1.47 -> 1.48) 

---- Diffs:

================================================================
Index: SOURCES/squid.init
diff -u SOURCES/squid.init:1.47 SOURCES/squid.init:1.48
--- SOURCES/squid.init:1.47	Fri Nov 23 13:20:38 2007
+++ SOURCES/squid.init	Fri Nov 23 13:44:42 2007
@@ -58,9 +58,23 @@
 CACHE_SWAP=$(awk '/^cache_dir/{print $3}' /etc/squid/squid.conf)
 [ -z "$CACHE_SWAP" ] && CACHE_SWAP=/var/cache/squid
 
+check_cache_dirs() {
+	local need_init=0 dir
+	for dir in $CACHE_SWAP; do
+		if [ ! -d $dir/00 ]; then
+			need_init=1
+		fi
+	done
+	if [ $need_init = 1 ]; then
+		show "Initializing Squid cache dirs"
+		squid -z -F -D >> /var/log/squid/squid.out 2>&1 && ok || fail
+	fi
+}
+
 start() {
 	# Check if the service is already running?
 	if [ ! -f /var/lock/subsys/squid ]; then
+		check_cache_dirs
 		msg_starting Squid
 		daemon squid $SQUID_OPTS
 		RETVAL=$?
@@ -108,7 +122,7 @@
 # NOTE: needs running squid
 configtest() {
 	show "Checking squid config syntax"
-	squid -k check
+	squid -k check >> /var/log/squid/squid.out 2>&1
 	RETVAL=$?
 	[ $RETVAL = 0 ] && ok || fail
 }
@@ -159,8 +173,8 @@
 	exit $?
 	;;
   init)
-	nls "Initializing %s" squid
-	squid -z
+	show "Initializing Squid"; echo
+	check_cache_dirs
 	;;
   *)
 	msg_usage "$0 {start|stop|init|restart|reload|force-reload|status}"
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/SOURCES/squid.init?r1=1.47&r2=1.48&f=u



More information about the pld-cvs-commit mailing list