summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEray Aslan <eras@gentoo.org>2012-10-23 07:01:47 +0000
committerEray Aslan <eras@gentoo.org>2012-10-23 07:01:47 +0000
commite0a0e13c5770ba75c36093c433427e06a84b69a7 (patch)
treef525d5c584d1c90175348af9b22aa682d7a97a4f /net-proxy/squid
parentAdd comment for doxygen patch. (diff)
downloadgentoo-2-e0a0e13c5770ba75c36093c433427e06a84b69a7.tar.gz
gentoo-2-e0a0e13c5770ba75c36093c433427e06a84b69a7.tar.bz2
gentoo-2-e0a0e13c5770ba75c36093c433427e06a84b69a7.zip
Init script: need net -> use net
(Portage version: 2.2.0_alpha141/cvs/Linux x86_64, signed Manifest commit with key 0x77F1F175586A3B1F)
Diffstat (limited to 'net-proxy/squid')
-rw-r--r--net-proxy/squid/ChangeLog6
-rw-r--r--net-proxy/squid/files/squid.initd-logrotate-r1121
-rw-r--r--net-proxy/squid/files/squid.initd-r1128
-rw-r--r--net-proxy/squid/squid-3.2.3.ebuild6
4 files changed, 257 insertions, 4 deletions
diff --git a/net-proxy/squid/ChangeLog b/net-proxy/squid/ChangeLog
index 52fc8ad9886c..a08d722d6ed0 100644
--- a/net-proxy/squid/ChangeLog
+++ b/net-proxy/squid/ChangeLog
@@ -1,6 +1,10 @@
# ChangeLog for net-proxy/squid
# Copyright 1999-2012 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/net-proxy/squid/ChangeLog,v 1.356 2012/10/23 06:55:06 eras Exp $
+# $Header: /var/cvsroot/gentoo-x86/net-proxy/squid/ChangeLog,v 1.357 2012/10/23 07:01:47 eras Exp $
+
+ 23 Oct 2012; Eray Aslan <eras@gentoo.org> +files/squid.initd-logrotate-r1,
+ +files/squid.initd-r1, squid-3.2.3.ebuild:
+ Init script: need net -> use net
*squid-3.2.3 (23 Oct 2012)
diff --git a/net-proxy/squid/files/squid.initd-logrotate-r1 b/net-proxy/squid/files/squid.initd-logrotate-r1
new file mode 100644
index 000000000000..0285fae25c55
--- /dev/null
+++ b/net-proxy/squid/files/squid.initd-logrotate-r1
@@ -0,0 +1,121 @@
+#!/sbin/runscript
+# Copyright 1999-2012 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-r1,v 1.1 2012/10/23 07:01:47 eras Exp $
+
+extra_started_commands="reload"
+
+depend() {
+ use dns net
+}
+
+upprocval() {
+ [ -f $1 ] || return 0
+ if [ `cat $1` -lt $2 ]; then
+ echo $2 > $1
+ fi
+}
+
+# Try to increase the # of filedescriptors we can open.
+maxfds() {
+ [ -n "$SQUID_MAXFD" ] || return
+ [ $SQUID_MAXFD -le 8192 ] || SQUID_MAXFD=8192
+ local minimal_file_max=$(($SQUID_MAXFD + 4096))
+ upprocval /proc/sys/fs/file-max $minimal_file_max
+ if /usr/sbin/squid -v | grep -q "\--enable-epoll" ; then
+ upprocval /proc/sys/fs/epoll/max_user_watches $minimal_file_max
+ fi
+ ulimit -n $SQUID_MAXFD
+}
+
+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/${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 directory ${x%/*}"
+ local ORIG_UMASK=$(umask)
+ umask 027
+
+ 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
+ fi
+ done
+
+ return 0
+}
+
+start() {
+ checkconfig || return 1
+ ebegin "Starting ${SVCNAME}"
+ KRB5_KTNAME="${SQUID_KEYTAB}" /usr/sbin/squid ${SQUID_OPTS} -f /etc/squid/${SVCNAME}.conf
+ eend $? && sleep 1
+}
+
+stop() {
+ ebegin "Stopping ${SVCNAME}"
+ if /usr/sbin/squid -k shutdown -f /etc/squid/${SVCNAME}.conf ; then
+ # Now we have to wait until squid has _really_ stopped.
+ sleep 1
+ if [ -f /var/run/${SVCNAME}.pid ] ; then
+ einfon "Waiting for squid to shutdown ."
+ cnt=0
+ while [ -f /var/run/${SVCNAME}.pid ] ; do
+ cnt=$(expr $cnt + 1)
+ if [ $cnt -gt 60 ] ; then
+ # Waited 120 seconds now. Fail.
+ echo
+ eend 1 "Failed."
+ break
+ fi
+ sleep 2
+ echo -n "."
+ done
+ echo
+ fi
+ else
+ eerror "Squid shutdown failed, probably service is already down."
+ fi
+ eend 0
+}
+
+reload() {
+ checkconfig || return 1
+ ebegin "Reloading ${SVCNAME}"
+ /usr/sbin/squid -k reconfigure -f /etc/squid/${SVCNAME}.conf
+ eend $?
+}
diff --git a/net-proxy/squid/files/squid.initd-r1 b/net-proxy/squid/files/squid.initd-r1
new file mode 100644
index 000000000000..86998494172a
--- /dev/null
+++ b/net-proxy/squid/files/squid.initd-r1
@@ -0,0 +1,128 @@
+#!/sbin/runscript
+# Copyright 1999-2012 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-proxy/squid/files/squid.initd-r1,v 1.1 2012/10/23 07:01:47 eras Exp $
+
+extra_started_commands="reload rotate"
+
+depend() {
+ use dns net
+}
+
+upprocval() {
+ [ -f $1 ] || return 0
+ if [ `cat $1` -lt $2 ]; then
+ echo $2 > $1
+ fi
+}
+
+# Try to increase the # of filedescriptors we can open.
+maxfds() {
+ [ -n "$SQUID_MAXFD" ] || return
+ [ $SQUID_MAXFD -le 8192 ] || SQUID_MAXFD=8192
+ local minimal_file_max=$(($SQUID_MAXFD + 4096))
+ upprocval /proc/sys/fs/file-max $minimal_file_max
+ if /usr/sbin/squid -v | grep -q "\--enable-epoll" ; then
+ upprocval /proc/sys/fs/epoll/max_user_watches $minimal_file_max
+ fi
+ ulimit -n $SQUID_MAXFD
+}
+
+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/${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 directory ${x%/*}"
+ local ORIG_UMASK=$(umask)
+ umask 027
+
+ 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
+ fi
+ done
+
+ return 0
+}
+
+start() {
+ checkconfig || return 1
+ ebegin "Starting ${SVCNAME}"
+ KRB5_KTNAME="${SQUID_KEYTAB}" /usr/sbin/squid ${SQUID_OPTS} -f /etc/squid/${SVCNAME}.conf
+ eend $? && sleep 1
+}
+
+stop() {
+ ebegin "Stopping ${SVCNAME}"
+ if /usr/sbin/squid -k shutdown -f /etc/squid/${SVCNAME}.conf ; then
+ # Now we have to wait until squid has _really_ stopped.
+ sleep 1
+ if [ -f /var/run/${SVCNAME}.pid ] ; then
+ einfon "Waiting for squid to shutdown ."
+ cnt=0
+ while [ -f /var/run/${SVCNAME}.pid ] ; do
+ cnt=$(expr $cnt + 1)
+ if [ $cnt -gt 60 ] ; then
+ # Waited 120 seconds now. Fail.
+ echo
+ eend 1 "Failed."
+ break
+ fi
+ sleep 2
+ echo -n "."
+ done
+ echo
+ fi
+ else
+ eerror "Squid shutdown failed, probably service is already down."
+ fi
+ eend 0
+}
+
+reload() {
+ checkconfig || return 1
+ ebegin "Reloading ${SVCNAME}"
+ /usr/sbin/squid -k reconfigure -f /etc/squid/${SVCNAME}.conf
+ eend $?
+}
+
+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/squid-3.2.3.ebuild b/net-proxy/squid/squid-3.2.3.ebuild
index 851c95d78eda..34e95fc93444 100644
--- a/net-proxy/squid/squid-3.2.3.ebuild
+++ b/net-proxy/squid/squid-3.2.3.ebuild
@@ -1,6 +1,6 @@
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/net-proxy/squid/squid-3.2.3.ebuild,v 1.1 2012/10/23 06:55:06 eras Exp $
+# $Header: /var/cvsroot/gentoo-x86/net-proxy/squid/squid-3.2.3.ebuild,v 1.2 2012/10/23 07:01:47 eras Exp $
EAPI=4
inherit eutils pam toolchain-funcs autotools linux-info user versionator
@@ -213,11 +213,11 @@ src_install() {
newpamd "${FILESDIR}/squid.pam" squid
newconfd "${FILESDIR}/squid.confd" squid
if use logrotate; then
- newinitd "${FILESDIR}/squid.initd-logrotate" squid
+ newinitd "${FILESDIR}/squid.initd-logrotate-r1" squid
insinto /etc/logrotate.d
newins "${FILESDIR}/squid.logrotate" squid
else
- newinitd "${FILESDIR}/squid.initd" squid
+ newinitd "${FILESDIR}/squid.initd-r1" squid
exeinto /etc/cron.weekly
newexe "${FILESDIR}/squid.cron" squid.cron
fi