From ca76f01b51e1fe77cbd85e0ff15892209b6624bc Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Thu, 6 Aug 2020 17:19:58 +0200 Subject: 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 --- net-vpn/wireguard-tools/files/wg-quick.init | 35 ++++++++++++++++++++++ .../wireguard-tools-1.0.20200513.ebuild | 1 + 2 files changed, 36 insertions(+) create mode 100644 net-vpn/wireguard-tools/files/wg-quick.init (limited to 'net-vpn/wireguard-tools') 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() { -- cgit v1.2.3-65-gdbad