summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason A. Donenfeld <zx2c4@gentoo.org>2020-08-06 17:19:58 +0200
committerJason A. Donenfeld <zx2c4@gentoo.org>2020-08-06 17:20:31 +0200
commitca76f01b51e1fe77cbd85e0ff15892209b6624bc (patch)
tree97adec19f6c6591614f867735dfb41542a26a2b7 /net-vpn/wireguard-tools
parentapp/admin-conky-1.10.8-r10: Patched crash on virtual Pulseaudio sinks (diff)
downloadgentoo-ca76f01b51e1fe77cbd85e0ff15892209b6624bc.tar.gz
gentoo-ca76f01b51e1fe77cbd85e0ff15892209b6624bc.tar.bz2
gentoo-ca76f01b51e1fe77cbd85e0ff15892209b6624bc.zip
net-vpn/wireguard-tools: add init script
Closes: https://github.com/gentoo/gentoo/pull/16794 Closes: https://bugs.gentoo.org/672582 Package-Manager: Portage-3.0.1, Repoman-2.3.23 Signed-off-by: Jason A. Donenfeld <zx2c4@gentoo.org>
Diffstat (limited to 'net-vpn/wireguard-tools')
-rw-r--r--net-vpn/wireguard-tools/files/wg-quick.init35
-rw-r--r--net-vpn/wireguard-tools/wireguard-tools-1.0.20200513.ebuild1
2 files changed, 36 insertions, 0 deletions
diff --git a/net-vpn/wireguard-tools/files/wg-quick.init b/net-vpn/wireguard-tools/files/wg-quick.init
new file mode 100644
index 000000000000..ad6874104051
--- /dev/null
+++ b/net-vpn/wireguard-tools/files/wg-quick.init
@@ -0,0 +1,35 @@
+#!/sbin/openrc-run
+# Copyright 2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+name="WireGuard"
+description="WireGuard via wg-quick(8)"
+
+depend() {
+ need net
+ use dns
+}
+
+CONF="${SVCNAME#*.}"
+
+checkconfig() {
+ if [ "$CONF" = "$SVCNAME" ]; then
+ eerror "You cannot call this init script directly. You must create a symbolic link to it with the configuration name:"
+ eerror " ln -s /etc/init.d/wg-quick /etc/init.d/wg-quick.vpn0"
+ eerror "And then call it instead:"
+ eerror " /etc/init.d/wg-quick.vpn0 start"
+ return 1
+ fi
+}
+
+start() {
+ ebegin "Starting $description for $CONF"
+ wg-quick up "$CONF"
+ eend $? "Failed to start $description for $CONF"
+}
+
+stop() {
+ ebegin "Stopping $description for $CONF"
+ wg-quick down "$CONF"
+ eend $? "Failed to stop $description for $CONF"
+}
diff --git a/net-vpn/wireguard-tools/wireguard-tools-1.0.20200513.ebuild b/net-vpn/wireguard-tools/wireguard-tools-1.0.20200513.ebuild
index 05151edab944..17cfcbbb8f2e 100644
--- a/net-vpn/wireguard-tools/wireguard-tools-1.0.20200513.ebuild
+++ b/net-vpn/wireguard-tools/wireguard-tools-1.0.20200513.ebuild
@@ -93,6 +93,7 @@ src_install() {
SYSTEMDUNITDIR="$(systemd_get_systemunitdir)" \
PREFIX="${EPREFIX}/usr" \
-C src install
+ use wg-quick && newinitd "${FILESDIR}/wg-quick.init" wg-quick
}
pkg_postinst() {