X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=src%2Finitscripts%2Finit.d%2Fsquid;h=c641c7d37987ce7fa753e4fc0df2aacba71da6d7;hb=dfb08084ba25b03f27ca41c04f0a0f1e2dace6d5;hp=1a1425d0c695f1b2a4628b1100006f9b5d708826;hpb=80c7f007fe5c70b1bbfa56286806e73ae1e93bfa;p=people%2Fteissler%2Fipfire-2.x.git diff --git a/src/initscripts/init.d/squid b/src/initscripts/init.d/squid index 1a1425d0c..c641c7d37 100644 --- a/src/initscripts/init.d/squid +++ b/src/initscripts/init.d/squid @@ -15,8 +15,8 @@ transparent() { 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 + if [ -z "${TRANSPARENT_PORT}" ]; then + TRANSPARENT_PORT=800 fi LOCALIP=`cat /var/ipfire/red/local-ipaddress | tr -d \n` @@ -43,7 +43,7 @@ transparent() { iptables -t nat -A SQUID -i $1 -p tcp -d $LOCALIP --dport 80 -j RETURN - iptables -t nat -A SQUID -i $1 -p tcp --dport 80 -j REDIRECT --to-port $PROXY_PORT + iptables -t nat -A SQUID -i $1 -p tcp --dport 80 -j REDIRECT --to-port "${TRANSPARENT_PORT}" } case "$1" in @@ -62,13 +62,25 @@ case "$1" in 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 "Creating Squid swap directories..." + /usr/sbin/squid -z >/dev/null 2>&1 + evaluate_retval + + # Make sure, that the process above has finished. + counter=5 + while [ ${counter} -gt 0 ]; do + if pidofproc -s /usr/sbin/squid; then + sleep 1 + else + break + fi + done + boot_mesg "Starting Squid Proxy Server..." - loadproc /usr/sbin/squid -z >/dev/null 2>&1 loadproc /usr/sbin/squid fi @@ -86,10 +98,31 @@ case "$1" in boot_mesg "Stopping Squid Proxy Server..." squid -k shutdown >/dev/null 2>&1 evaluate_retval - killproc /usr/bin/squidGuard >/dev/null - killproc /usr/sbin/updxlrator >/dev/null - killproc /usr/bin/squidclamav >/dev/null + + # 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 ;;