aboutsummaryrefslogtreecommitdiff
path: root/network/dnsproxy-bin/rc.dnsproxy
blob: f71496a4679dcc8b1c6f8fe6ed6754ce129c4ab8 (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
# Start/stop/restart the dnsproxy

if [[ $EUID -ne 0 ]]; then
   echo "This script must be run as root" 1>&2
   exit 1
fi

name="dnsproxy"
pidfiles=/run/"$name"
mkdir -p $pidfiles
if /bin/id "$name" &>/dev/null; then
  chown $name:$name $pidfiles
  daemon="/usr/bin/daemon --name=$name --pidfiles=$pidfiles --user=$name"
else
  daemon="/usr/bin/daemon --name=$name --pidfiles=$pidfiles"
fi

start_dnsproxy() {
if $daemon --running; then
  echo "$name is already running"
else
  echo "Starting $name..."
  $daemon -- /usr/sbin/dnsproxy --config-path=/etc/dnsproxy.yaml
fi
}

stop_dnsproxy() {
if $daemon --running; then
  echo "Stopping $name..."
  $daemon --stop
else
  echo "$name is not running"
fi
}

restart_dnsproxy() {
  stop_dnsproxy
  sleep 1
  start_dnsproxy
}

status_dnsproxy() {
  $daemon --running --verbose
}

case "$1" in
'start')
  start_dnsproxy
  ;;
'stop')
  stop_dnsproxy
  ;;
'restart')
  restart_dnsproxy
  ;;
'status')
  status_dnsproxy
  ;;
*)
  echo "usage $0 start|stop|restart|status"
esac