2020-12-18 20:50:42 +00:00
|
|
|
#!/sbin/openrc-run
|
|
|
|
|
|
|
|
description="Control wg-quick connections"
|
|
|
|
|
2021-06-01 23:17:41 +00:00
|
|
|
: ${WIREGUARD_INTERFACE:=wg0}
|
|
|
|
|
2020-12-18 20:50:42 +00:00
|
|
|
check_interface() {
|
2021-06-01 23:17:41 +00:00
|
|
|
if [ -d /sys/class/net/"$WIREGUARD_INTERFACE" ]; then
|
2020-12-18 20:50:42 +00:00
|
|
|
mark_service_started
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
mark_service_stopped
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
start() {
|
2021-06-02 15:58:52 +00:00
|
|
|
check_interface || /usr/bin/wg-quick up "${WIREGUARD_CONFIG:-WIREGUARD_INTERFACE}"
|
2020-12-18 20:50:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
stop() {
|
2021-06-02 15:58:52 +00:00
|
|
|
check_interface && /usr/bin/wg-quick down "${WIREGUARD_CONFIG:-WIREGUARD_INTERFACE}"
|
2020-12-18 20:50:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
restart() {
|
|
|
|
stop
|
|
|
|
start
|
|
|
|
}
|