1 |
commit: ca76f01b51e1fe77cbd85e0ff15892209b6624bc |
2 |
Author: Jason A. Donenfeld <zx2c4 <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Aug 6 15:19:58 2020 +0000 |
4 |
Commit: Jason A. Donenfeld <zx2c4 <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Aug 6 15:20:31 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ca76f01b |
7 |
|
8 |
net-vpn/wireguard-tools: add init script |
9 |
|
10 |
Closes: https://github.com/gentoo/gentoo/pull/16794 |
11 |
Closes: https://bugs.gentoo.org/672582 |
12 |
Package-Manager: Portage-3.0.1, Repoman-2.3.23 |
13 |
Signed-off-by: Jason A. Donenfeld <zx2c4 <AT> gentoo.org> |
14 |
|
15 |
net-vpn/wireguard-tools/files/wg-quick.init | 35 ++++++++++++++++++++++ |
16 |
.../wireguard-tools-1.0.20200513.ebuild | 1 + |
17 |
2 files changed, 36 insertions(+) |
18 |
|
19 |
diff --git a/net-vpn/wireguard-tools/files/wg-quick.init b/net-vpn/wireguard-tools/files/wg-quick.init |
20 |
new file mode 100644 |
21 |
index 00000000000..ad687410405 |
22 |
--- /dev/null |
23 |
+++ b/net-vpn/wireguard-tools/files/wg-quick.init |
24 |
@@ -0,0 +1,35 @@ |
25 |
+#!/sbin/openrc-run |
26 |
+# Copyright 2020 Gentoo Authors |
27 |
+# Distributed under the terms of the GNU General Public License v2 |
28 |
+ |
29 |
+name="WireGuard" |
30 |
+description="WireGuard via wg-quick(8)" |
31 |
+ |
32 |
+depend() { |
33 |
+ need net |
34 |
+ use dns |
35 |
+} |
36 |
+ |
37 |
+CONF="${SVCNAME#*.}" |
38 |
+ |
39 |
+checkconfig() { |
40 |
+ if [ "$CONF" = "$SVCNAME" ]; then |
41 |
+ eerror "You cannot call this init script directly. You must create a symbolic link to it with the configuration name:" |
42 |
+ eerror " ln -s /etc/init.d/wg-quick /etc/init.d/wg-quick.vpn0" |
43 |
+ eerror "And then call it instead:" |
44 |
+ eerror " /etc/init.d/wg-quick.vpn0 start" |
45 |
+ return 1 |
46 |
+ fi |
47 |
+} |
48 |
+ |
49 |
+start() { |
50 |
+ ebegin "Starting $description for $CONF" |
51 |
+ wg-quick up "$CONF" |
52 |
+ eend $? "Failed to start $description for $CONF" |
53 |
+} |
54 |
+ |
55 |
+stop() { |
56 |
+ ebegin "Stopping $description for $CONF" |
57 |
+ wg-quick down "$CONF" |
58 |
+ eend $? "Failed to stop $description for $CONF" |
59 |
+} |
60 |
|
61 |
diff --git a/net-vpn/wireguard-tools/wireguard-tools-1.0.20200513.ebuild b/net-vpn/wireguard-tools/wireguard-tools-1.0.20200513.ebuild |
62 |
index 05151edab94..17cfcbbb8f2 100644 |
63 |
--- a/net-vpn/wireguard-tools/wireguard-tools-1.0.20200513.ebuild |
64 |
+++ b/net-vpn/wireguard-tools/wireguard-tools-1.0.20200513.ebuild |
65 |
@@ -93,6 +93,7 @@ src_install() { |
66 |
SYSTEMDUNITDIR="$(systemd_get_systemunitdir)" \ |
67 |
PREFIX="${EPREFIX}/usr" \ |
68 |
-C src install |
69 |
+ use wg-quick && newinitd "${FILESDIR}/wg-quick.init" wg-quick |
70 |
} |
71 |
|
72 |
pkg_postinst() { |