aports/openrc/wireguard/runfile

26 lines
415 B
Plaintext
Raw Normal View History

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