wok annotate squid/stuff/etc/init.d/squid @ rev 3340

Add: childsplay (0.90.2)
author Claudinei Pereira <claudinei@slitaz.org>
date Thu Jun 11 02:15:26 2009 +0000 (2009-06-11)
parents 4784eb863cc5
children 1b6281d68d9f
rev   line source
pascal@1253 1 #!/bin/sh
pascal@1253 2 # /etc/init.d/squid : Start, stop and restart Squid proxy server on SliTaz, at
pascal@1253 3 # boot time or with the command line.
pascal@1253 4 #
pascal@1253 5 # To start Squid proxy server at boot time, just put squid in the $RUN_DAEMONS
pascal@1253 6 # variable of /etc/rcS.conf and configure options with /etc/daemons.conf
pascal@1253 7 #
pascal@1253 8 . /etc/init.d/rc.functions
pascal@1253 9 . /etc/daemons.conf
pascal@1253 10
pascal@1253 11 NAME=Squid
pascal@1253 12 DESC="Squid proxy server"
pascal@1253 13 DAEMON=/usr/sbin/squid
pascal@1253 14 OPTIONS=$SQUID_OPTIONS
pascal@1253 15 PIDFILE=/var/run/squid.pid
pascal@1253 16 http_port=$(grep ^http_port /etc/squid/squid.conf | awk '{ print $2 }')
pascal@1253 17 [ -n "$http_port" ] || http_port=3128
pascal@1253 18 [ -n "$OPTIONS" ] || OPTIONS="-a $http_port"
pascal@1253 19
pascal@1253 20 case "$1" in
pascal@1253 21 start)
pascal@1253 22 if [ -f $PIDFILE ] ; then
pascal@1253 23 echo "$NAME already running."
pascal@1253 24 exit 1
pascal@1253 25 fi
pascal@1253 26 cache_dir=$(grep ^cache_dir /etc/squid/squid.conf | awk '{ print $3 }')
pascal@1253 27 [ -n "$cache_dir" ] || cache_dir=/var/cache
pascal@1253 28 if [ -d "$cache_dir" -a ! -d "$cache_dir/00" ]; then
pascal@1253 29 echo -n "Creating squid spool directory structure"
erjo@2384 30 $DAEMON -z > /dev/null 2>&1
pascal@1253 31 status
pascal@1253 32 fi
pascal@1253 33 echo -n "Starting $DESC: $NAME... "
pascal@1253 34 $DAEMON $OPTIONS
pascal@1253 35 status
pascal@1253 36 sleep 2
pascal@1253 37 ;;
pascal@1253 38 stop)
pascal@1253 39 if [ ! -f $PIDFILE ] ; then
pascal@1253 40 echo "$NAME is not running."
pascal@1253 41 exit 1
pascal@1253 42 fi
pascal@1253 43 echo -n "Stopping $DESC: $NAME... "
erjo@2384 44 $DAEMON -k kill
pascal@1253 45 status
erjo@2384 46 rm -f $PIDFILE
pascal@1253 47 sleep 2
pascal@1253 48 ;;
erjo@2384 49 reload)
erjo@2384 50 if [ ! -f $PIDFILE ] ; then
erjo@2384 51 echo "$NAME is not running."
erjo@2384 52 exit 1
erjo@2384 53 fi
erjo@2384 54 echo -n "Reloading $DESC configuration... "
erjo@2384 55 $DAEMON -k reconfigure
erjo@2384 56 status
erjo@2384 57 ;;
pascal@1253 58 restart)
pascal@1253 59 if [ ! -f $PIDFILE ] ; then
pascal@1253 60 echo "$NAME is not running."
pascal@1253 61 exit 1
pascal@1253 62 fi
pascal@1253 63 echo -n "Restarting $DESC: $NAME... "
erjo@2384 64 $DAEMON -k kill && $DAEMON $OPTIONS
pascal@1253 65 status
pascal@1253 66 sleep 2
pascal@1253 67 ;;
pascal@1253 68 *)
pascal@1253 69 echo ""
erjo@2384 70 echo -e "\033[1mUsage:\033[0m /etc/init.d/`basename $0` [start|stop|reload|restart]"
pascal@1253 71 echo ""
pascal@1253 72 exit 1
pascal@1253 73 ;;
pascal@1253 74 esac
pascal@1253 75
pascal@1253 76 exit 0