From a8bfe6abb693150e9ee01ea6e8d672fc074d1f1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Wed, 12 Sep 2018 00:19:18 +0200 Subject: New multiconfig design --- files/wireguard/mwg.init | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100755 files/wireguard/mwg.init (limited to 'files/wireguard/mwg.init') 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 +} -- cgit v1.2.3