aports/main/wireguard-tools/wg-quick.initd
FintasticMan d6ec6c73a5 main/wireguard-tools: add wg-quick init script
Script from Gentoo's wireguard-tools package.
To use, symlink the script to wg-quick.$interface.
2024-05-15 14:30:03 +00:00

39 lines
885 B
Bash

#!/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"
}