2024-03-05 19:47:48 +01:00
|
|
|
#!/bin/dash
|
|
|
|
|
2024-07-20 16:51:19 +02:00
|
|
|
config=/etc/wireguard/ovh.conf
|
|
|
|
interface_name="ovh"
|
2024-03-05 19:47:48 +01:00
|
|
|
|
|
|
|
is_connected (){
|
2024-07-20 16:51:19 +02:00
|
|
|
if ip link show up | grep -q "$interface_name"; then
|
2024-03-05 19:47:48 +01:00
|
|
|
echo "true"
|
2024-07-20 16:51:19 +02:00
|
|
|
else
|
|
|
|
echo "false"
|
2024-03-05 19:47:48 +01:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
connected="$(is_connected)"
|
|
|
|
|
|
|
|
if [ "$1" = "toggle" ]; then
|
|
|
|
if [ "$connected" = "false" ]; then
|
2024-07-20 16:51:19 +02:00
|
|
|
sudo wg-quick up "$config" > /dev/null
|
2024-03-05 19:47:48 +01:00
|
|
|
else
|
2024-07-20 16:51:19 +02:00
|
|
|
sudo wg-quick down "$config" > /dev/null
|
2024-03-05 19:47:48 +01:00
|
|
|
fi
|
|
|
|
eww update vpn_status="{\"connected\": $(is_connected)}"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "{\"connected\": $(is_connected)}"
|