main/wireguard-tools: add wg-quick init script

Script from Gentoo's wireguard-tools package.
To use, symlink the script to wg-quick.$interface.
This commit is contained in:
FintasticMan 2024-03-19 21:04:36 +01:00 committed by Celeste
parent c06cdf4559
commit d6ec6c73a5
3 changed files with 58 additions and 2 deletions

View file

@ -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
"

View file

@ -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"
}

View file

@ -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