diff options
-rw-r--r-- | net-proxy/squid/ChangeLog | 6 | ||||
-rw-r--r-- | net-proxy/squid/files/squid.confd | 4 | ||||
-rw-r--r-- | net-proxy/squid/files/squid.initd | 56 | ||||
-rw-r--r-- | net-proxy/squid/files/squid.initd-logrotate | 50 |
4 files changed, 84 insertions, 32 deletions
diff --git a/net-proxy/squid/ChangeLog b/net-proxy/squid/ChangeLog index 70d444b084e9..fc0d774fe88e 100644 --- a/net-proxy/squid/ChangeLog +++ b/net-proxy/squid/ChangeLog @@ -1,6 +1,10 @@ # ChangeLog for net-proxy/squid # Copyright 1999-2009 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/net-proxy/squid/ChangeLog,v 1.286 2009/10/22 22:30:13 mrness Exp $ +# $Header: /var/cvsroot/gentoo-x86/net-proxy/squid/ChangeLog,v 1.287 2009/10/25 08:35:47 mrness Exp $ + + 25 Oct 2009; Alin Năstac <mrness@gentoo.org> files/squid.confd, + files/squid.initd, files/squid.initd-logrotate: + Add support for multiple instances of squid service (#287941). *squid-3.1.0.14_beta (22 Oct 2009) diff --git a/net-proxy/squid/files/squid.confd b/net-proxy/squid/files/squid.confd index a27ecd388f0e..67956bf64154 100644 --- a/net-proxy/squid/files/squid.confd +++ b/net-proxy/squid/files/squid.confd @@ -1,10 +1,10 @@ # Copyright 1999-2004 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/net-proxy/squid/files/squid.confd,v 1.2 2008/11/30 19:20:44 mrness Exp $ +# $Header: /var/cvsroot/gentoo-x86/net-proxy/squid/files/squid.confd,v 1.3 2009/10/25 08:35:46 mrness Exp $ # Config file for /etc/init.d/squid -SQUID_OPTS="-DYC" +SQUID_OPTS="-YC" # Max. number of filedescriptors to use. You can increase this on a busy # cache to a maximum of (currently) 8192 filedescriptors. Default is 1024. diff --git a/net-proxy/squid/files/squid.initd b/net-proxy/squid/files/squid.initd index be047c53b554..59c96bc67f42 100644 --- a/net-proxy/squid/files/squid.initd +++ b/net-proxy/squid/files/squid.initd @@ -1,11 +1,12 @@ #!/sbin/runscript # Copyright 1999-2006 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/net-proxy/squid/files/squid.initd,v 1.11 2009/08/16 11:01:46 mrness Exp $ +# $Header: /var/cvsroot/gentoo-x86/net-proxy/squid/files/squid.initd,v 1.12 2009/10/25 08:35:46 mrness Exp $ opts="${opts} reload rotate" depend() { + use dns need net } @@ -29,24 +30,47 @@ maxfds() { } checkconfig() { + if [ ! -f /etc/squid/${SVCNAME}.conf ]; then + eerror "You need to create /etc/squid/${SVCNAME}.conf first." + eerror "An example can be found in /etc/squid/squid.conf.default" + return 1 + fi + + local PIDFILE=$(awk '/^[ \t]*pid_filename[ \t]+/ { print $2 }' < /etc/squid/${SVCNAME}.conf) + [ -z ${PIDFILE} ] && PIDFILE=/var/run/squid.pid + if [ /var/run/${SVCNAME}.pid != ${PIDFILE} ]; then + eerror "/etc/squid/${SVCNAME}.conf must set pid_filename to" + eerror " /var/run/${SVCNAME}.pid" + eerror "CAUTION: http_port, cache_dir and *_log parameters must be different than" + eerror " in any other instance of squid." + return 1 + fi + maxfds - - local CACHE_SWAP=$(awk '/^[ \t]*cache_dir[ \t]+/ { if ($2 == "coss" ) printf "%s/stripe ", $3 ; else printf "%s/00 ", $3; }' < /etc/squid/squid.conf) + + local CACHE_SWAP=$(awk '/^[ \t]*cache_dir[ \t]+/ { if ($2 == "coss" ) printf "%s/stripe ", $3 ; else printf "%s/00 ", $3; }' < /etc/squid/${SVCNAME}.conf) [ -z "$CACHE_SWAP" ] && CACHE_SWAP="/var/cache/squid/00" local x for x in $CACHE_SWAP ; do if [ ! -e $x ] ; then - ebegin "Initializing cache directories" + ebegin "Initializing cache directory ${x%/*}" local ORIG_UMASK=$(umask) umask 027 - local INIT_CACHE_RESPONSE="$(/usr/sbin/squid -z -N -D 2>&1)" + + if ! (mkdir -p ${x%/*} && chown squid ${x%/*}) ; then + eend 1 + return 1 + fi + + local INIT_CACHE_RESPONSE="$(/usr/sbin/squid -z -N -f /etc/squid/${SVCNAME}.conf 2>&1)" if [ $? != 0 ] || echo "$INIT_CACHE_RESPONSE" | grep -q "erminated abnormally" ; then umask $ORIG_UMASK eend 1 echo "$INIT_CACHE_RESPONSE" return 1 fi + umask $ORIG_UMASK eend 0 break @@ -58,20 +82,20 @@ checkconfig() { start() { checkconfig || return 1 - ebegin "Starting squid" - KRB5_KTNAME="${SQUID_KEYTAB}" /usr/sbin/squid ${SQUID_OPTS} + ebegin "Starting ${SVCNAME}" + KRB5_KTNAME="${SQUID_KEYTAB}" /usr/sbin/squid ${SQUID_OPTS} -f /etc/squid/${SVCNAME}.conf eend $? && sleep 1 } stop() { - ebegin "Stopping squid" - /usr/sbin/squid -k shutdown + ebegin "Stopping ${SVCNAME}" + /usr/sbin/squid -k shutdown -f /etc/squid/${SVCNAME}.conf # Now we have to wait until squid has _really_ stopped. sleep 1 - if [ -f /var/run/squid.pid ] ; then + if [ -f /var/run/${SVCNAME}.pid ] ; then einfon "Waiting for squid to shutdown ." cnt=0 - while [ -f /var/run/squid.pid ] ; do + while [ -f /var/run/${SVCNAME}.pid ] ; do cnt=$(expr $cnt + 1) if [ $cnt -gt 60 ] ; then # Waited 120 seconds now. Fail. @@ -89,14 +113,14 @@ stop() { reload() { checkconfig || return 1 - ebegin "Reloading squid" - /usr/sbin/squid -k reconfigure + ebegin "Reloading ${SVCNAME}" + /usr/sbin/squid -k reconfigure -f /etc/squid/${SVCNAME}.conf eend $? } rotate() { - service_started squid || return 1 - ebegin "Rotating logs" - /usr/sbin/squid -k rotate + service_started ${SVCNAME} || return 1 + ebegin "Rotating ${SVCNAME} logs" + /usr/sbin/squid -k rotate -f /etc/squid/${SVCNAME}.conf eend $? } diff --git a/net-proxy/squid/files/squid.initd-logrotate b/net-proxy/squid/files/squid.initd-logrotate index 3a802bfec348..40bf525af217 100644 --- a/net-proxy/squid/files/squid.initd-logrotate +++ b/net-proxy/squid/files/squid.initd-logrotate @@ -1,11 +1,12 @@ #!/sbin/runscript # Copyright 1999-2006 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/net-proxy/squid/files/squid.initd-logrotate,v 1.9 2009/08/16 11:01:46 mrness Exp $ +# $Header: /var/cvsroot/gentoo-x86/net-proxy/squid/files/squid.initd-logrotate,v 1.10 2009/10/25 08:35:46 mrness Exp $ opts="${opts} reload" depend() { + use dns need net } @@ -29,24 +30,47 @@ maxfds() { } checkconfig() { + if [ ! -f /etc/squid/${SVCNAME}.conf ]; then + eerror "You need to create /etc/squid/${SVCNAME}.conf first." + eerror "An example can be found in /etc/squid/squid.conf.default" + return 1 + fi + + local PIDFILE=$(awk '/^[ \t]*pid_filename[ \t]+/ { print $2 }' < /etc/squid/${SVCNAME}.conf) + [ -z ${PIDFILE} ] && PIDFILE=/var/run/squid.pid + if [ /var/run/${SVCNAME}.pid != ${PIDFILE} ]; then + eerror "/etc/squid/${SVCNAME}.conf must set pid_filename to" + eerror " /var/run/${SVCNAME}.pid" + eerror "CAUTION: http_port, cache_dir and *_log parameters must be different than" + eerror " in any other instance of squid." + return 1 + fi + maxfds - - local CACHE_SWAP=$(awk '/^[ \t]*cache_dir[ \t]+/ { if ($2 == "coss" ) printf "%s/stripe ", $3 ; else printf "%s/00 ", $3; }' < /etc/squid/squid.conf) + + local CACHE_SWAP=$(awk '/^[ \t]*cache_dir[ \t]+/ { if ($2 == "coss" ) printf "%s/stripe ", $3 ; else printf "%s/00 ", $3; }' < /etc/squid/${SVCNAME}.conf) [ -z "$CACHE_SWAP" ] && CACHE_SWAP="/var/cache/squid/00" local x for x in $CACHE_SWAP ; do if [ ! -e $x ] ; then - ebegin "Initializing cache directories" + ebegin "Initializing cache directory ${x%/*}" local ORIG_UMASK=$(umask) umask 027 - local INIT_CACHE_RESPONSE="$(/usr/sbin/squid -z -N -D 2>&1)" + + if ! (mkdir -p ${x%/*} && chown squid ${x%/*}) ; then + eend 1 + return 1 + fi + + local INIT_CACHE_RESPONSE="$(/usr/sbin/squid -z -N -f /etc/squid/${SVCNAME}.conf 2>&1)" if [ $? != 0 ] || echo "$INIT_CACHE_RESPONSE" | grep -q "erminated abnormally" ; then umask $ORIG_UMASK eend 1 echo "$INIT_CACHE_RESPONSE" return 1 fi + umask $ORIG_UMASK eend 0 break @@ -58,20 +82,20 @@ checkconfig() { start() { checkconfig || return 1 - ebegin "Starting squid" - KRB5_KTNAME="${SQUID_KEYTAB}" /usr/sbin/squid ${SQUID_OPTS} + ebegin "Starting ${SVCNAME}" + KRB5_KTNAME="${SQUID_KEYTAB}" /usr/sbin/squid ${SQUID_OPTS} -f /etc/squid/${SVCNAME}.conf eend $? && sleep 1 } stop() { - ebegin "Stopping squid" - /usr/sbin/squid -k shutdown + ebegin "Stopping ${SVCNAME}" + /usr/sbin/squid -k shutdown -f /etc/squid/${SVCNAME}.conf # Now we have to wait until squid has _really_ stopped. sleep 1 - if [ -f /var/run/squid.pid ] ; then + if [ -f /var/run/${SVCNAME}.pid ] ; then einfon "Waiting for squid to shutdown ." cnt=0 - while [ -f /var/run/squid.pid ] ; do + while [ -f /var/run/${SVCNAME}.pid ] ; do cnt=$(expr $cnt + 1) if [ $cnt -gt 60 ] ; then # Waited 120 seconds now. Fail. @@ -89,7 +113,7 @@ stop() { reload() { checkconfig || return 1 - ebegin "Reloading squid" - /usr/sbin/squid -k reconfigure + ebegin "Reloading ${SVCNAME}" + /usr/sbin/squid -k reconfigure -f /etc/squid/${SVCNAME}.conf eend $? } |