diff options
author | Jason A. Donenfeld <zx2c4@gentoo.org> | 2018-05-28 01:56:51 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-07-10 23:10:22 +0200 |
commit | 66af4525ff3a4530a165443f459134f1f60283f8 (patch) | |
tree | 54c601a91cf282b2bec4087fc366a04bb1c86dbe /net | |
parent | net/iproute2: improve DAD tentative wait/output. (diff) | |
download | netifrc-66af4525ff3a4530a165443f459134f1f60283f8.tar.gz netifrc-66af4525ff3a4530a165443f459134f1f60283f8.tar.bz2 netifrc-66af4525ff3a4530a165443f459134f1f60283f8.zip |
net/wireguard: import from ebuild
Signed-off-by: Jason A. Donenfeld <zx2c4@gentoo.org>
Diffstat (limited to 'net')
-rw-r--r-- | net/Makefile | 2 | ||||
-rw-r--r-- | net/wireguard.sh | 53 |
2 files changed, 54 insertions, 1 deletions
diff --git a/net/Makefile b/net/Makefile index 347e89c..390f8d8 100644 --- a/net/Makefile +++ b/net/Makefile @@ -14,7 +14,7 @@ INC-Linux= adsl.sh apipa.sh arping.sh bonding.sh br2684ctl.sh bridge.sh \ ccwgroup.sh clip.sh ethtool.sh iproute2.sh ifplugd.sh ip6to4.sh \ ipppd.sh iwconfig.sh netplugd.sh pppd.sh pump.sh tuntap.sh udhcpc.sh \ vlan.sh macvlan.sh ip6rd.sh firewalld.sh dummy.sh hsr.sh l2tp.sh \ - iw.sh + iw.sh wireguard.sh SRCS-NetBSD= ifwatchd.sh.in INC-NetBSD= ifwatchd.sh diff --git a/net/wireguard.sh b/net/wireguard.sh new file mode 100644 index 0000000..efa45b0 --- /dev/null +++ b/net/wireguard.sh @@ -0,0 +1,53 @@ +# Copyright (c) 2016 Gentoo Foundation +# Released under the 2-clause BSD license. + +wireguard_depend() +{ + program /usr/bin/wg + after interface +} + +wireguard_pre_start() +{ + [ "${IFACE#wg}" != "$IFACE" ] || return 0 + + ip link delete dev "$IFACE" type wireguard 2>/dev/null + ebegin "Creating WireGuard interface $IFACE" + if ! ip link add dev "$IFACE" type wireguard; then + e=$? + eend $e + return $e + fi + eend 0 + + ebegin "Configuring WireGuard interface $IFACE" + set -- $(_get_array "wireguard_$IFVAR") + if [ $# -eq 1 ]; then + /usr/bin/wg setconf "$IFACE" "$1" + else + eval /usr/bin/wg set "$IFACE" "$@" + fi + e=$? + if [ $e -eq 0 ]; then + _up + e=$? + if [ $e -eq 0 ]; then + eend $e + return $e + fi + fi + ip link delete dev "$IFACE" type wireguard 2>/dev/null + eend $e + return $e +} + +wireguard_post_stop() +{ + [ "${IFACE#wg}" != "$IFACE" ] || return 0 + + ebegin "Removing WireGuard interface $IFACE" + ip link delete dev "$IFACE" type wireguard + e=$? + eend $e + return $e +} |