Gentoo Archives: gentoo-commits

From: Jason Donenfeld <zx2c4@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/netifrc:master commit in: net/
Date: Tue, 10 Jul 2018 21:11:22
Message-Id: 1531257022.66af4525ff3a4530a165443f459134f1f60283f8.zx2c4@OpenRC
1 commit: 66af4525ff3a4530a165443f459134f1f60283f8
2 Author: Jason A. Donenfeld <zx2c4 <AT> gentoo <DOT> org>
3 AuthorDate: Sun May 27 23:56:51 2018 +0000
4 Commit: Jason Donenfeld <zx2c4 <AT> gentoo <DOT> org>
5 CommitDate: Tue Jul 10 21:10:22 2018 +0000
6 URL: https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=66af4525
7
8 net/wireguard: import from ebuild
9
10 Signed-off-by: Jason A. Donenfeld <zx2c4 <AT> gentoo.org>
11
12 net/Makefile | 2 +-
13 net/wireguard.sh | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
14 2 files changed, 54 insertions(+), 1 deletion(-)
15
16 diff --git a/net/Makefile b/net/Makefile
17 index 347e89c..390f8d8 100644
18 --- a/net/Makefile
19 +++ b/net/Makefile
20 @@ -14,7 +14,7 @@ INC-Linux= adsl.sh apipa.sh arping.sh bonding.sh br2684ctl.sh bridge.sh \
21 ccwgroup.sh clip.sh ethtool.sh iproute2.sh ifplugd.sh ip6to4.sh \
22 ipppd.sh iwconfig.sh netplugd.sh pppd.sh pump.sh tuntap.sh udhcpc.sh \
23 vlan.sh macvlan.sh ip6rd.sh firewalld.sh dummy.sh hsr.sh l2tp.sh \
24 - iw.sh
25 + iw.sh wireguard.sh
26
27 SRCS-NetBSD= ifwatchd.sh.in
28 INC-NetBSD= ifwatchd.sh
29
30 diff --git a/net/wireguard.sh b/net/wireguard.sh
31 new file mode 100644
32 index 0000000..efa45b0
33 --- /dev/null
34 +++ b/net/wireguard.sh
35 @@ -0,0 +1,53 @@
36 +# Copyright (c) 2016 Gentoo Foundation
37 +# Released under the 2-clause BSD license.
38 +
39 +wireguard_depend()
40 +{
41 + program /usr/bin/wg
42 + after interface
43 +}
44 +
45 +wireguard_pre_start()
46 +{
47 + [ "${IFACE#wg}" != "$IFACE" ] || return 0
48 +
49 + ip link delete dev "$IFACE" type wireguard 2>/dev/null
50 + ebegin "Creating WireGuard interface $IFACE"
51 + if ! ip link add dev "$IFACE" type wireguard; then
52 + e=$?
53 + eend $e
54 + return $e
55 + fi
56 + eend 0
57 +
58 + ebegin "Configuring WireGuard interface $IFACE"
59 + set -- $(_get_array "wireguard_$IFVAR")
60 + if [ $# -eq 1 ]; then
61 + /usr/bin/wg setconf "$IFACE" "$1"
62 + else
63 + eval /usr/bin/wg set "$IFACE" "$@"
64 + fi
65 + e=$?
66 + if [ $e -eq 0 ]; then
67 + _up
68 + e=$?
69 + if [ $e -eq 0 ]; then
70 + eend $e
71 + return $e
72 + fi
73 + fi
74 + ip link delete dev "$IFACE" type wireguard 2>/dev/null
75 + eend $e
76 + return $e
77 +}
78 +
79 +wireguard_post_stop()
80 +{
81 + [ "${IFACE#wg}" != "$IFACE" ] || return 0
82 +
83 + ebegin "Removing WireGuard interface $IFACE"
84 + ip link delete dev "$IFACE" type wireguard
85 + e=$?
86 + eend $e
87 + return $e
88 +}