blob: 4e9d45da1c5d0477388548545395374568b2e833 (
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
|
#!/sbin/openrc-run
# Copyright 1999-2018 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
depend() {
use logger
}
reload() {
if [ -z "$IP" ]; then
eerror "Variable IP has to be defined in service config file"
exit 1
fi
ip link set down dev mwg
ip addr flush mwg
ip addr add "$IP/24" dev mwg
wg setconf mwg "/etc/mwg/config"
ip link set up dev mwg
}
start() {
# Add wireguard interface
if ! ip link list mwg 2>/dev/null >&2; then
ip link add dev mwg type wireguard
fi
# Reload/Load
reload
mark_service_started
}
stop() {
# Remove wireguard interface
ip link del dev mwg || true
}
|