summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlin Năstac <mrness@gentoo.org>2006-01-09 11:51:47 +0000
committerAlin Năstac <mrness@gentoo.org>2006-01-09 11:51:47 +0000
commit0850d9ed8c250ed0b991313d50dcc6e44c54f54c (patch)
tree83b4522ad48dded565f846fd7ae8b638dcdf574c /net-proxy/squid/files
parentVersion bump. (diff)
downloadgentoo-2-0850d9ed8c250ed0b991313d50dcc6e44c54f54c.tar.gz
gentoo-2-0850d9ed8c250ed0b991313d50dcc6e44c54f54c.tar.bz2
gentoo-2-0850d9ed8c250ed0b991313d50dcc6e44c54f54c.zip
Add rotate functionality to init script (#118376).
(Portage version: 2.0.53)
Diffstat (limited to 'net-proxy/squid/files')
-rw-r--r--net-proxy/squid/files/squid.initd11
-rw-r--r--net-proxy/squid/files/squid.initd-logrotate82
-rw-r--r--net-proxy/squid/files/squid.logrotate (renamed from net-proxy/squid/files/squid-logrotate)0
3 files changed, 91 insertions, 2 deletions
diff --git a/net-proxy/squid/files/squid.initd b/net-proxy/squid/files/squid.initd
index 950f1bf9fe84..01f4b06c9677 100644
--- a/net-proxy/squid/files/squid.initd
+++ b/net-proxy/squid/files/squid.initd
@@ -1,9 +1,9 @@
#!/sbin/runscript
# 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.initd,v 1.2 2005/12/31 10:20:17 mrness Exp $
+# $Header: /var/cvsroot/gentoo-x86/net-proxy/squid/files/squid.initd,v 1.3 2006/01/09 11:51:47 mrness Exp $
-opts="${opts} reload"
+opts="${opts} reload rotate"
depend() {
need net
@@ -80,3 +80,10 @@ reload() {
/usr/sbin/squid -k reconfigure
eend $?
}
+
+rotate() {
+ service_started squid || return 1
+ ebegin "Rotating logs"
+ /usr/sbin/squid -k rotate
+ eend $?
+}
diff --git a/net-proxy/squid/files/squid.initd-logrotate b/net-proxy/squid/files/squid.initd-logrotate
new file mode 100644
index 000000000000..b43bd3dcf069
--- /dev/null
+++ b/net-proxy/squid/files/squid.initd-logrotate
@@ -0,0 +1,82 @@
+#!/sbin/runscript
+# 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.initd-logrotate,v 1.1 2006/01/09 11:51:47 mrness Exp $
+
+opts="${opts} reload"
+
+depend() {
+ need net
+}
+
+# Try to increase the # of filedescriptors we can open.
+maxfds() {
+ [ -n "$SQUID_MAXFD" ] || return
+ [ -f /proc/sys/fs/file-max ] || return 0
+ [ $SQUID_MAXFD -le 8192 ] || SQUID_MAXFD=8192
+ global_file_max=`cat /proc/sys/fs/file-max`
+ minimal_file_max=$(($SQUID_MAXFD + 4096))
+ if [ "$global_file_max" -lt $minimal_file_max ]
+ then
+ echo $minimal_file_max > /proc/sys/fs/file-max
+ fi
+ ulimit -n $SQUID_MAXFD
+}
+
+checkconfig() {
+ maxfds
+ CACHE_SWAP=`sed -e 's/#.*//g' /etc/squid/squid.conf | \
+ grep cache_dir | awk '{ print $3 }'`
+ [ -z "$CACHE_SWAP" ] && CACHE_SWAP=/var/cache/squid
+ umask 027
+ for x in $CACHE_SWAP ; do
+ if [ ! -d $x/00 ] ; then
+ einfo "Initializing cache directory: $x"
+ cd $x
+ /usr/sbin/squid -z -F 2>/dev/null
+ if [ $? -ne 0 ] ; then
+ eerror "Error initializing: $x"
+ return 1
+ fi
+ fi
+ done
+}
+
+start() {
+ checkconfig || return 1
+ ebegin "Starting squid"
+ /usr/sbin/squid ${SQUID_OPTS}
+ eend $? && sleep 1
+}
+
+stop() {
+ ebegin "Stopping squid"
+ /usr/sbin/squid -k shutdown
+ # Now we have to wait until squid has _really_ stopped.
+ sleep 1
+ if [ -f /var/run/squid.pid ] ; then
+ einfon "Waiting ."
+ cnt=0
+ while [ -f /var/run/squid.pid ] ; do
+ cnt=`expr $cnt + 1`
+ if [ $cnt -gt 60 ] ; then
+ # Waited 120 seconds now. Fail.
+ eend 1 "Failed."
+ break
+ fi
+ sleep 2
+ echo -n "."
+ done
+ echo -n "done."
+ eend 0
+ else
+ eend 0
+ fi
+}
+
+reload() {
+ checkconfig || return 1
+ ebegin "Reloading squid"
+ /usr/sbin/squid -k reconfigure
+ eend $?
+}
diff --git a/net-proxy/squid/files/squid-logrotate b/net-proxy/squid/files/squid.logrotate
index 72486b016fbf..72486b016fbf 100644
--- a/net-proxy/squid/files/squid-logrotate
+++ b/net-proxy/squid/files/squid.logrotate