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

sane-backends, scons, scrot, shell-fm, smake, soundtouch, wireless_tools: fix man or doc path
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Jul 06 16:30:34 2016 +0200 (2016-07-06)
parents 1b6281d68d9f
children
rev   line source
pascal@1253 1 #!/bin/sh
al@19159 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
al@19159 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
al@19159 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@6170 22 if active_pidfile $PIDFILE squid ; then
al@19159 23 _ '%s is already running.' $NAME
pascal@1253 24 exit 1
pascal@1253 25 fi
al@19159 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
al@19159 29 action 'Creating squid spool directory structure'
al@19159 30 $DAEMON -z >/dev/null 2>&1
pascal@1253 31 status
pascal@1253 32 fi
al@19159 33 action 'Starting %s: %s...' "$DESC" $NAME
pascal@1253 34 $DAEMON $OPTIONS
pascal@1253 35 status
pascal@1253 36 sleep 2
pascal@1253 37 ;;
pascal@1253 38 stop)
pascal@6170 39 if ! active_pidfile $PIDFILE squid ; then
al@19159 40 _ '%s is not running.' $NAME
pascal@1253 41 exit 1
pascal@1253 42 fi
al@19159 43 action 'Stopping %s: %s...' "$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)
pascal@6170 50 if ! active_pidfile $PIDFILE squid ; then
al@19159 51 _ '%s is not running.' $NAME
erjo@2384 52 exit 1
erjo@2384 53 fi
al@19159 54 action 'Reloading %s configuration...' $NAME
erjo@2384 55 $DAEMON -k reconfigure
erjo@2384 56 status
erjo@2384 57 ;;
pascal@1253 58 restart)
pascal@6170 59 if ! active_pidfile $PIDFILE squid ; then
al@19159 60 _ '%s is not running.' $NAME
pascal@1253 61 exit 1
pascal@1253 62 fi
al@19159 63 action 'Restarting %s: %s...' "$DESC" $NAME
al@19159 64 $DAEMON -k kill && $DAEMON $OPTIONS
pascal@1253 65 status
pascal@1253 66 sleep 2
pascal@1253 67 ;;
pascal@1253 68 *)
al@19159 69 emsg "<n><b>$(_ 'Usage:')</b> $0 [start|stop|restart|reload]"
al@19159 70 newline
pascal@1253 71 exit 1
pascal@1253 72 ;;
pascal@1253 73 esac
pascal@1253 74
pascal@1253 75 exit 0