28 lines
425 B
Plaintext
28 lines
425 B
Plaintext
#!/sbin/openrc-run
|
|
|
|
description="Control wg-quick connections"
|
|
|
|
: ${WIREGUARD_INTERFACE:=wg0}
|
|
|
|
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_INTERFACE"
|
|
}
|
|
|
|
stop() {
|
|
check_interface && /usr/bin/wg-quick down "$WIREGUARD_INTERFACE"
|
|
}
|
|
|
|
restart() {
|
|
stop
|
|
start
|
|
}
|