-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathnet.pia
executable file
·62 lines (52 loc) · 879 Bytes
/
net.pia
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
#!/sbin/openrc-run
command="/root/bin/pia-wg.sh"
: "${CONFIGDIR:=/var/cache/pia-wg}"
: "${CONFIG:=/etc/pia-wg/pia-wg.conf}"
extra_started_commands="reload"
depend() {
need net sysfs
after modules ip-rules
use logger
}
start_pre() {
if ! [ -e "$CONFIG" ]
then
echo "Please generate a config with pia-wg.sh and copy it to $CONFIG"
return 1
fi
if ! [ -w "$CONFIGDIR" ] || ! [ -d "$CONFIGDIR" ]
then
echo "$CONFIGDIR is not a writable directory"
return 1
fi
return 0
}
doconn() {
(
export CONFIGDIR="$CONFIGDIR"
export CONFIG="$CONFIG"
while "$command" "$@" 2>&1 | tee /var/log/pia-wg.log && [ ${PIPESTATUS[0]} -ne 0 ]
do
ewarn "Failed, retrying"
sleep 1
done
einfo "OK"
);
return 0
}
start() {
doconn -f
}
reload() {
doconn -r
}
restart() {
stop
start
}
stop() {
(
source "$CONFIG"
ip link del "${PIA_INTERFACE:-pia}"
);
}