blob: 6022096d910b9473e6d9316c6819f3f5e5902569 (
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
77
78
79
80
81
82
|
#!/bin/sh
INTERFACE=$1
STATUS=$2
# $INIT should be either "init" (System V) or "systemd".
INIT=`cat /proc/1/domm`
no_valid_init() {
echo 'No valid init system set. Please select either "init" or "systemd".'
exit 1
}
pdnsd_going_up() {
# Check whether pDNSd is already running before starting it.
case "$INIT" in
'systemd')
systemctl is-active pdnsd.service -q
if [ ! $? = 0 ]; then
systemctl start pdnsd.service
else
systemctl restart pdnsd.service
fi
;;
'init')
if [ `rc.d list|grep pdnsd|cut -f1 -d']'|cut -d'[' -f2` == 'STOPPED' ]; then
rc.d start pdnsd
else
rc.d restart pdnsd
fi
;;
*)
no_valid_init
;;
esac
}
pdnsd_going_down() {
# Check for active interface, take offline if none is active
if [ ! `nm-tool|grep State|cut -f2 -d' '` = 'connected' ]; then
case "$INIT" in
'systemd')
systemctl stop pdnsd.service
;;
'init')
rc.d stop pdnsd
;;
*)
no_valid_init
;;
esac
else
# If another interface is active, restart so we're sure we're using
# the active connection.
case "$INIT" in
'systemd')
systemctl restart pdnsd.service
;;
'init')
rc.d restart pdnsd
;;
*)
no_valid_init
;;
esac
fi
}
case "$STATUS" in
up)
pdnsd_going_up
;;
vpn-up)
pdnsd_going_up
;;
down)
pdnsd_going_down
;;
vpn-down)
pdnsd_going_down
;;
esac
|