aboutsummaryrefslogtreecommitdiff
path: root/files/wireguard
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2018-09-12 00:19:18 +0200
committerKarel Kočí <cynerd@email.cz>2018-09-12 00:19:18 +0200
commita8bfe6abb693150e9ee01ea6e8d672fc074d1f1c (patch)
treec5e6cc5166c56ad45a396d9af6d4063ad755d9d5 /files/wireguard
parent4e4d389127254c7404bc71a308129966bd9a8b07 (diff)
downloadmulticonfig-a8bfe6abb693150e9ee01ea6e8d672fc074d1f1c.tar.gz
multiconfig-a8bfe6abb693150e9ee01ea6e8d672fc074d1f1c.tar.bz2
multiconfig-a8bfe6abb693150e9ee01ea6e8d672fc074d1f1c.zip
New multiconfig design
Diffstat (limited to 'files/wireguard')
-rwxr-xr-xfiles/wireguard/mwg.init39
1 files changed, 39 insertions, 0 deletions
diff --git a/files/wireguard/mwg.init b/files/wireguard/mwg.init
new file mode 100755
index 0000000..4e9d45d
--- /dev/null
+++ b/files/wireguard/mwg.init
@@ -0,0 +1,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
+}