1 |
commit: bacd0610a70acbd102193c6c4374a02a7b3121c4 |
2 |
Author: Jason A. Donenfeld <zx2c4 <AT> gentoo <DOT> org> |
3 |
AuthorDate: Fri Oct 14 16:25:20 2016 +0000 |
4 |
Commit: Jason Donenfeld <zx2c4 <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri Oct 14 16:25:50 2016 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=bacd0610 |
7 |
|
8 |
net-misc/wireguard: add netifrc script |
9 |
|
10 |
Package-Manager: portage-2.3.2 |
11 |
|
12 |
net-misc/wireguard/files/wireguard-openrc.sh | 43 ++++++++++++++++++++++++ |
13 |
net-misc/wireguard/wireguard-0.0.20161014.ebuild | 2 ++ |
14 |
net-misc/wireguard/wireguard-9999.ebuild | 2 ++ |
15 |
3 files changed, 47 insertions(+) |
16 |
|
17 |
diff --git a/net-misc/wireguard/files/wireguard-openrc.sh b/net-misc/wireguard/files/wireguard-openrc.sh |
18 |
new file mode 100644 |
19 |
index 00000000..9c3df6a |
20 |
--- /dev/null |
21 |
+++ b/net-misc/wireguard/files/wireguard-openrc.sh |
22 |
@@ -0,0 +1,43 @@ |
23 |
+# Copyright (c) 2016 Gentoo Foundation |
24 |
+# All rights reserved. Released under the 2-clause BSD license. |
25 |
+ |
26 |
+wireguard_depend() |
27 |
+{ |
28 |
+ program /usr/bin/wg |
29 |
+ after interface |
30 |
+ before dhcp |
31 |
+} |
32 |
+ |
33 |
+wireguard_pre_start() |
34 |
+{ |
35 |
+ ip link delete dev "$IFACE" type wireguard 2>/dev/null |
36 |
+ ebegin "Creating WireGuard interface $IFACE" |
37 |
+ if ! ip link add dev "$IFACE" type wireguard; then |
38 |
+ eend $? |
39 |
+ return $? |
40 |
+ fi |
41 |
+ eend 0 |
42 |
+ |
43 |
+ ebegin "Configuring WireGuard interface $IFACE" |
44 |
+ set -- $(_get_array "wireguard_$IFVAR") |
45 |
+ if [[ -f $1 && $# -eq 1 ]]; then |
46 |
+ /usr/bin/wg setconf "$IFACE" "$1" |
47 |
+ else |
48 |
+ eval /usr/bin/wg set "$IFACE" "$@" |
49 |
+ fi |
50 |
+ if [ $? -eq 0 ]; then |
51 |
+ _up |
52 |
+ eend 0 |
53 |
+ return |
54 |
+ fi |
55 |
+ e=$? |
56 |
+ ip link delete dev "$IFACE" type wireguard 2>/dev/null |
57 |
+ eend $e |
58 |
+} |
59 |
+ |
60 |
+wireguard_post_stop() |
61 |
+{ |
62 |
+ ebegin "Removing WireGuard interface $IFACE" |
63 |
+ ip link delete dev "$IFACE" type wireguard |
64 |
+ eend $? |
65 |
+} |
66 |
|
67 |
diff --git a/net-misc/wireguard/wireguard-0.0.20161014.ebuild b/net-misc/wireguard/wireguard-0.0.20161014.ebuild |
68 |
index 83e13fc..86294fa 100644 |
69 |
--- a/net-misc/wireguard/wireguard-0.0.20161014.ebuild |
70 |
+++ b/net-misc/wireguard/wireguard-0.0.20161014.ebuild |
71 |
@@ -53,6 +53,8 @@ src_install() { |
72 |
dodoc -r contrib/examples |
73 |
linux-mod_src_install |
74 |
emake DESTDIR="${D}" PREFIX="${EPREFIX}/usr" -C src/tools install |
75 |
+ insinto /$(get_libdir)/netifrc/net |
76 |
+ newins "${FILESDIR}"/wireguard-openrc.sh wireguard.sh |
77 |
} |
78 |
|
79 |
pkg_postinst() { |
80 |
|
81 |
diff --git a/net-misc/wireguard/wireguard-9999.ebuild b/net-misc/wireguard/wireguard-9999.ebuild |
82 |
index 83e13fc..86294fa 100644 |
83 |
--- a/net-misc/wireguard/wireguard-9999.ebuild |
84 |
+++ b/net-misc/wireguard/wireguard-9999.ebuild |
85 |
@@ -53,6 +53,8 @@ src_install() { |
86 |
dodoc -r contrib/examples |
87 |
linux-mod_src_install |
88 |
emake DESTDIR="${D}" PREFIX="${EPREFIX}/usr" -C src/tools install |
89 |
+ insinto /$(get_libdir)/netifrc/net |
90 |
+ newins "${FILESDIR}"/wireguard-openrc.sh wireguard.sh |
91 |
} |
92 |
|
93 |
pkg_postinst() { |