summaryrefslogtreecommitdiff
path: root/network/squid/rc.squid.new
diff options
context:
space:
mode:
authorDavid Somero <dsomero@hotmail.com>2010-05-11 20:01:44 +0200
committerRobby Workman <rworkman@slackbuilds.org>2010-05-11 20:01:44 +0200
commit2bc0efd73ea73d28b0c180711de99249c8609878 (patch)
treee5feff8d64bbfb52ffbcc5e7c861837b78419e3e /network/squid/rc.squid.new
parent592862627db3069274d6d2b9aed677b29f518fe4 (diff)
downloadslackbuilds-2bc0efd73ea73d28b0c180711de99249c8609878.tar.gz
network/squid: Added to 12.0 repository
Diffstat (limited to 'network/squid/rc.squid.new')
-rw-r--r--network/squid/rc.squid.new83
1 files changed, 83 insertions, 0 deletions
diff --git a/network/squid/rc.squid.new b/network/squid/rc.squid.new
new file mode 100644
index 0000000000..4810dae64f
--- /dev/null
+++ b/network/squid/rc.squid.new
@@ -0,0 +1,83 @@
+#!/bin/sh
+# Start/stop/restart/reload the Squid Internet Object Cache (squid)
+# To make Squid start automatically at boot, make this
+# file executable: chmod 755 /etc/rc.d/rc.Squid
+#
+# Written for Slackware Linux by Erik Jan Tromp
+# Modified by David Somero <xgizzmo@slackbuilds.org>
+
+SQUIDCFG=/etc/squid/squid.conf
+SQUIDCMD=/usr/sbin/squid
+
+if [ ! -r $SQUIDCFG ]; then
+ echo "Please set the correct path to $SQUIDCFG"
+ exit 1
+fi
+
+if [ ! -x $SQUIDCMD ]; then
+ echo "$SQUIDCMD not found"
+ exit 1
+fi
+
+squid_start() {
+ # Create cache directory hierarchy if needed
+ ALL_DIRS=$(awk '/^cache_dir/ {print $3}' $SQUIDCFG)
+ [ -z "$ALL_DIRS" ] && ALL_DIRS=/var/cache/squid
+
+ for CACHE_DIR in $ALL_DIRS ; do
+ if [ ! -d $CACHE_DIR/00 ] ; then
+ echo "Creating swap directories: $SQUIDCMD -z"
+ $SQUIDCMD -z 2> /dev/null
+ break
+ fi
+ done
+
+ echo "Starting Squid: $SQUIDCMD -DF"
+ $SQUIDCMD -DF
+}
+
+squid_stop() {
+ COUNTDOWN=$(awk '/^shutdown_lifetime/ {print $2}' $SQUIDCFG)
+ [ -z "$COUNTDOWN" ] && COUNTDOWN=30
+
+ echo -n "Shutting down Squid in $COUNTDOWN seconds: "
+ $SQUIDCMD -k shutdown 2> /dev/null
+ while $SQUIDCMD -k check 2> /dev/null ; do
+ sleep 1
+ echo -n .
+ COUNTDOWN=$[ $COUNTDOWN - 1 ]
+ if [ $COUNTDOWN -le 0 ] ; then
+ $SQUIDCMD -k interrupt 2> /dev/null
+ sleep 1
+ break
+ fi
+ done
+ echo
+}
+
+squid_restart() {
+ squid_stop
+ sleep 1
+ squid_start
+}
+
+squid_reload() {
+ $SQUIDCMD -k reconfigure 2> /dev/null
+}
+
+case "$1" in
+'start')
+ squid_start
+ ;;
+'stop')
+ squid_stop
+ ;;
+'restart')
+ squid_restart
+ ;;
+'reload')
+ squid_reload
+ ;;
+*)
+ echo "usage: $0 start|stop|restart|reload"
+esac