2021-01-25 10:53:58 +01:00
|
|
|
#!/sbin/openrc-run
|
|
|
|
|
|
|
|
name="WireGuard"
|
|
|
|
description="WireGuard via wg-quicker"
|
|
|
|
|
|
|
|
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-quicker /etc/init.d/wg-quicker.vpn0"
|
|
|
|
eerror "And then call it instead:"
|
|
|
|
eerror " /etc/init.d/wg-quicker.vpn0 start"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
start() {
|
2021-04-27 09:29:15 +02:00
|
|
|
checkconfig || return 1
|
2021-01-25 10:53:58 +01:00
|
|
|
ebegin "Starting $description for $CONF"
|
2021-03-08 09:17:06 +01:00
|
|
|
/usr/local/bin/wg-quicker up "$CONF"
|
2021-01-25 10:53:58 +01:00
|
|
|
eend $? "Failed to start $description for $CONF"
|
|
|
|
}
|
|
|
|
|
|
|
|
stop() {
|
|
|
|
ebegin "Stopping $description for $CONF"
|
2021-03-08 09:17:06 +01:00
|
|
|
/usr/local/bin/wg-quicker down "$CONF"
|
2021-01-25 10:53:58 +01:00
|
|
|
eend $? "Failed to stop $description for $CONF"
|
|
|
|
}
|