squid: revamp init
authorRoman I Khimov <khimov@altell.ru>
Fri, 19 Mar 2010 10:58:32 +0000 (13:58 +0300)
committerRoman I Khimov <khimov@altell.ru>
Sat, 20 Mar 2010 15:01:50 +0000 (18:01 +0300)
Configure squid to create PID file by default, use SQUID_ARGS variable,
wait for it to actually stop when stopping (takes some time for squid
to do it).

Signed-off-by: Roman I Khimov <khimov@altell.ru>
recipes/squid/squid.inc
recipes/squid/squid/squid.init

index ff3789c..9004b6f 100644 (file)
@@ -1,6 +1,6 @@
 DESCRIPTION = "Squid is a caching proxy for the Web supporting HTTP, HTTPS, FTP, and more"
 LICENSE = "GPLv2"
-INC_PR = "r3"
+INC_PR = "r4"
 DEPENDS = "squid-native-${PV}"
 
 SRC_URI = "http://www.squid-cache.org/Versions/v2/${SQUID_MAJOR}/squid-${PV}.tar.bz2;name=squid-${PV} \
@@ -42,6 +42,7 @@ do_install_append() {
        mv ${D}${sysconfdir}/mime.conf.default ${D}${sysconfdir}/squid/
        mv ${D}${sysconfdir}/squid.conf.default ${D}${sysconfdir}/squid/
        install -m 0644 ${WORKDIR}/squid-volatiles ${D}${sysconfdir}/default/volatiles/squid
+       sed -ri "s,^\#?\ *(pid_filename.+)$,\1," ${D}${sysconfdir}/squid/squid.conf
 }
 
 # this packages the languages better and saves some space, installs
index 61d9de4..d829cf9 100644 (file)
@@ -3,7 +3,7 @@ DAEMON=/usr/sbin/squid
 NAME=squid
 DESC="Squid HTTP proxy"
 PIDFILE=/var/run/squid.pid
-SQUID_ARGS="-D -sYC"
+SQUID_ARGS="-D -sY"
 
 test -f $DAEMON || exit 0
 
@@ -36,11 +36,25 @@ start() {
         chown $owner $ldr
     fi
 
-    start-stop-daemon -S -p $PIDFILE -x $DAEMON
+    start-stop-daemon -S -p $PIDFILE -x $DAEMON -- $SQUID_ARGS
 }
 
 stop() {
-        start-stop-daemon -K -p $PIDFILE -x $DAEMON
+       EX=0
+       CNT=1
+       while [ $EX -eq 0 -a $CNT -lt 15 ]; do
+               echo -n .
+               sleep 1
+               start-stop-daemon -K -p $PIDFILE 1>/dev/null 2>&1
+               EX=$?
+               CNT=`expr $CNT + 1`
+       done
+       if [ $CNT -eq 15 ]; then
+               echo "failed."
+       else
+               echo "done."
+               rm -f $PIDFILE
+       fi
 }
 
 case "$1" in
@@ -50,9 +64,8 @@ case "$1" in
         echo "done."
        ;;
     stop)
-        echo -n "Stopping $DESC: $NAME... "
+        echo -n "Stopping $DESC: $NAME"
         stop
-        echo "done."
         ;;
     restart)
         echo "Restarting $DESC: $NAME... "