aports/openrc/wireguard/runfile

32 lines
495 B
Plaintext

#!/sbin/openrc-run
description="Control wg-quick connections"
: ${WIREGUARD_INTERFACE:=wg0}
depend() {
after firewall
}
check_interface() {
if [ -d /sys/class/net/"$WIREGUARD_INTERFACE" ]; then
mark_service_started
return 0
fi
mark_service_stopped
return 1
}
start() {
check_interface || /usr/bin/wg-quick up "${WIREGUARD_CONFIG:-WIREGUARD_INTERFACE}"
}
stop() {
check_interface && /usr/bin/wg-quick down "${WIREGUARD_CONFIG:-WIREGUARD_INTERFACE}"
}
restart() {
stop
start
}