]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blobdiff - src/initscripts/init.d/squid
squid: Speed up the stop process.
[people/teissler/ipfire-2.x.git] / src / initscripts / init.d / squid
index 4930548539ea318cc0c8c10e92f92ece09852f33..08a3029a202e802092fe4af0b5b2894a8aae99f2 100644 (file)
@@ -7,12 +7,13 @@
 chown -R squid:squid /var/log/squid
 chown -R squid:squid /var/log/squidGuard
 
+
 transparent() {
                DEVICE=$1
-               
+
                eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings)
                eval $(/usr/local/bin/readhash /var/ipfire/proxy/settings)
-               
+
                # If the proxy port is not set we set the default to 800.
                if [ -z $PROXY_PORT ]; then
                        PROXY_PORT=800
@@ -47,15 +48,30 @@ transparent() {
 
 case "$1" in
        start)
-               boot_mesg "Starting Squid Proxy Server..."
-               
-               if [ -e /var/ipfire/proxy/enable -o -e /var/ipfire/proxy/enable_blue ]; then
-                       loadproc /usr/sbin/squid -D -z >/dev/null 2>&1
-                       loadproc /usr/sbin/squid -D
+               getpids "squid"
+
+               if [ -n "${pidlist}" ]; then
+                       echo -e "Squid is already running with Process"\
+                               "ID(s) ${pidlist}.${NORMAL}"
+               evaluate_retval
+               exit
                fi
 
+
+               eval $(/usr/local/bin/readhash /var/ipfire/proxy/advanced/settings)
                eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings)
 
+               if [ -e /var/ipfire/proxy/enable -o -e /var/ipfire/proxy/enable_blue ]; then
+
+                       # Add Address to errorpage stylesheet
+                       sed "s|XXXhostXXX|$GREEN_ADDRESS|g" /var/ipfire/proxy/errorpage-$ERR_DESIGN.css > \
+                               /etc/squid/errorpage.css
+
+                       boot_mesg "Starting Squid Proxy Server..."
+                       loadproc /usr/sbin/squid -z >/dev/null 2>&1
+                       loadproc /usr/sbin/squid
+               fi
+
                if [ -e /var/ipfire/proxy/transparent ]; then
                        transparent $GREEN_DEV
                fi
@@ -65,20 +81,50 @@ case "$1" in
                ;;
 
        stop)
-               boot_mesg "Stopping Squid Proxy Server..."
-               iptables -t nat -F SQUID
-               squid -k shutdown >/dev/null 2>&1
-               evaluate_retval
-               killproc /usr/sbin/squid >/dev/null
-               killproc /usr/bin/squidGuard >/dev/null
+                       iptables -t nat -F SQUID
+               if [ -e /var/run/squid.pid ]; then
+                       boot_mesg "Stopping Squid Proxy Server..."
+                       squid -k shutdown >/dev/null 2>&1
+                       evaluate_retval
+
+                       # Stop squidGuard, updxlrator, squidclamav
+                       # and redirect_wrappers.                        
+                       killproc /usr/bin/squidGuard >/dev/null &
+                       killproc /usr/sbin/updxlrator >/dev/null &
+                       killproc /usr/bin/squidclamav >/dev/null &
+                       killproc /usr/sbin/redirect_wrapper >/dev/null &
+
+                       # Wait until all redirectors have been stopped.
+                       wait
+
+                       # If squid is still running, wait up to 30 seconds
+                       # before we go on to kill it.
+                       counter=30
+
+                       while [ ${counter} -gt 0 ]; do
+                               statusproc /usr/sbin/squid >/dev/null && break;
+                               sleep 1
+                               counter=$(( ${counter} - 1))
+                       done
+
+                       # Kill squid service, if still running.
+                       killproc /usr/sbin/squid >/dev/null
+
+                       # Trash remain pid file from squid.
+                       rm -rf /var/run/squid.pid       
+               fi
                ;;
 
        restart)
                $0 stop
-               sleep 1
+               sleep 5
                $0 start
                ;;
 
+       reconfigure)
+       /usr/sbin/squid -k reconfigure
+               ;;
+
        status)
                statusproc /usr/sbin/squid
                statusproc /usr/lib/squid/unlinkd
@@ -91,6 +137,9 @@ case "$1" in
                sleep 1
                $0 start
                ;;
+       setperms)
+               chown -R nobody.squid /var/updatecache/
+               ;;
 
        *)
                echo "Usage: $0 {start|stop|restart|status|flush}"