summaryrefslogtreecommitdiffstats
path: root/network/dnscrypt-proxy/rc.dnscrypt-proxy
blob: 49cd4dc9849cd7d360d7a9f90226311559525a9b (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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/sh

# Init file for dnscrypt-proxy

CONFDIR="/etc/dnscrypt-proxy"
LOGDIR="/var/log/dnscrypt-proxy"
RUNDIR="/var/run/dnscrypt-proxy"

OPTS="-config $CONFDIR/dnscrypt-proxy.toml -pidfile $RUNDIR/dnscrypt-proxy.pid -logfile $LOGDIR/dnscrypt-proxy.log"

PID=$(cat /var/run/dnscrypt-proxy/dnscrypt-proxy.pid 2>/dev/null)

start() {
    echo "Starting DNSCrypt-proxy"
    /usr/bin/dnscrypt-proxy $OPTS &
}

stop() {
    echo "Stopping DNSCrypt-proxy"

if [ -z $PID ]; then
    echo "Not running"
    exit 0
fi

if kill -15 $PID 2>/dev/null; then
    echo "Stopped"
    rm $RUNDIR/dnscrypt-proxy.pid 2>/dev/null
else
    sleep 1
if kill -9 $PID 2>/dev/null; then
    echo "Killed"
    rm $RUNDIR/dnscrypt-proxy.pid 2>/dev/null
else
    echo "Error"
    exit 1
fi
fi

}

status() {

if [ -z $PID ]; then
    echo "Not running"
    exit 0
else
    echo "Running"
    exit 0
fi

}

case "$1" in

start)
	start
    ;;

stop)
    stop
;;

restart)
    stop
    sleep 3
    start
;;

status)
    status
;;

*)
	echo "Usage: $0 (start|stop|restart|status)"
esac