aboutsummaryrefslogtreecommitdiff
path: root/src/squid/squid
blob: da5534427a048ad92e03060ce1eb141daf661d54 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash

# source application-specific settings
[[ -f /etc/conf.d/squid ]] && . /etc/conf.d/squid

. /etc/rc.conf
. /etc/rc.d/functions

pidfile=/run/squid.pid
{ read -r PID </run/squid.pid; } 2>/dev/null
if [[ $pid && ! /proc/$pid/exe -ef /usr/sbin/squid ]]; then
  rm /run/squid.pid
fi

case $1 in
  start)
    stat_busy "Starting squid"
    if [[ $PID ]] || ! squid $SQUID_ARGS; then
      stat_fail
    else
      add_daemon squid
      stat_done
    fi
    ;;

  stop)
    stat_busy "Stopping squid"
    if [[ -z $PID ]] || ! squid -k shutdown &>/dev/null; then
      stat_fail
    else
      # squid takes forever to shutdown all its listening FDs
      while [[ /proc/$PID/exe -ef /usr/sbin/squid ]]; do
        stat_append "."
        sleep 3
      done
      rm_daemon squid
      stat_done
    fi
    ;;

  restart)
    $0 stop
    $0 start
    ;;
  *)
    echo "usage: $0 {start|stop|restart}"
esac
exit 0