diff options
Diffstat (limited to 'net-vpn/wireguard-tools/files/wg-quick.init')
-rw-r--r-- | net-vpn/wireguard-tools/files/wg-quick.init | 35 |
1 files changed, 35 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" +} |