From d6ec6c73a584a156fc8a5eb091f8b7d788e65792 Mon Sep 17 00:00:00 2001 From: FintasticMan <finlay.neon.kid@gmail.com> Date: Tue, 19 Mar 2024 21:04:36 +0100 Subject: [PATCH] main/wireguard-tools: add wg-quick init script Script from Gentoo's wireguard-tools package. To use, symlink the script to wg-quick.$interface. --- main/wireguard-tools/APKBUILD | 12 +++++- main/wireguard-tools/wg-quick.initd | 38 +++++++++++++++++++ .../wireguard-tools-openrc.post-install | 10 +++++ 3 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 main/wireguard-tools/wg-quick.initd create mode 100644 main/wireguard-tools/wireguard-tools-openrc.post-install diff --git a/main/wireguard-tools/APKBUILD b/main/wireguard-tools/APKBUILD index 3b5ee7703ca5..4a1042e00686 100644 --- a/main/wireguard-tools/APKBUILD +++ b/main/wireguard-tools/APKBUILD @@ -2,7 +2,7 @@ # Maintainer: Stuart Cardall <developer@it-offshore.co.uk> pkgname=wireguard-tools pkgver=1.0.20210914 -pkgrel=3 +pkgrel=4 pkgdesc="Next generation secure network tunnel: userspace tools" arch="all" url="https://www.wireguard.com" @@ -13,14 +13,19 @@ license="GPL-2.0-only" _wg_quick_deps="iproute2 bash openresolv" makedepends="libmnl-dev $_wg_quick_deps" depends="$pkgname-wg $pkgname-wg-quick" +install="$pkgname-openrc.post-install" subpackages=" $pkgname-doc $pkgname-bash-completion $pkgname-wg:_split $pkgname-wg-quick:_split:noarch + $pkgname-openrc " options="!check" -source="https://git.zx2c4.com/wireguard-tools/snapshot/wireguard-tools-$pkgver.tar.xz" +source=" + https://git.zx2c4.com/wireguard-tools/snapshot/wireguard-tools-$pkgver.tar.xz + wg-quick.initd + " build() { make -C src @@ -38,6 +43,8 @@ package() { find "$builddir"/contrib -name '.gitignore' -delete cp -rf "$builddir"/contrib "$pkgdir/usr/share/doc/$pkgname/" + + install -Dm755 "$srcdir"/wg-quick.initd "$pkgdir"/etc/init.d/wg-quick } _split() { @@ -53,4 +60,5 @@ _split() { sha512sums=" 6727ea65551dbb064457449b93a943bd6534ca93bc7fa5704c2f6826266c98688ee9ea28731fda57a5245d5f63c05f3899fcca54e40c0b6251b7c4796e957445 wireguard-tools-1.0.20210914.tar.xz +3de3edb359a786bdb8de06f496caced1293048c2ec489073c0525b4eca61365424ffde6a7eb899d7672db38872b6c67436b2e39019e92300ca5e590ba02c2e84 wg-quick.initd " diff --git a/main/wireguard-tools/wg-quick.initd b/main/wireguard-tools/wg-quick.initd new file mode 100644 index 000000000000..780472782031 --- /dev/null +++ b/main/wireguard-tools/wg-quick.initd @@ -0,0 +1,38 @@ +#!/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 + return 0 +} + +start() { + checkconfig || return 1 + ebegin "Starting $description for $CONF" + wg-quick up "$CONF" + eend $? "Failed to start $description for $CONF" +} + +stop() { + checkconfig || return 1 + ebegin "Stopping $description for $CONF" + wg-quick down "$CONF" + eend $? "Failed to stop $description for $CONF" +} diff --git a/main/wireguard-tools/wireguard-tools-openrc.post-install b/main/wireguard-tools/wireguard-tools-openrc.post-install new file mode 100644 index 000000000000..b7d43c7d55b4 --- /dev/null +++ b/main/wireguard-tools/wireguard-tools-openrc.post-install @@ -0,0 +1,10 @@ +#!/bin/sh + +cat 1>&2 <<EOF +* +* To use the WireGuard OpenRC script, you need to create a symbolic link to it with the configuration name: +* ln -s /etc/init.d/wg-quick /etc/init.d/wg-quick.wg0 +* And then call it instead: +* rc-service wg-quick.wg0 start +* +EOF -- GitLab