refactor(eww -> scripts -> vpn_status): Now using wireguard vpn

This commit is contained in:
GaspardCulis 2024-07-20 16:51:19 +02:00
parent 72ec110591
commit 7ace951889
No known key found for this signature in database
GPG key ID: BC18146756955609

View file

@ -1,13 +1,13 @@
#!/bin/dash #!/bin/dash
config=OVH config=/etc/wireguard/ovh.conf
interface_name="ovh"
is_connected (){ is_connected (){
openvpn3 session-stats --config OVH > /dev/null 2>&1 if ip link show up | grep -q "$interface_name"; then
if [ $? -ne 0 ] ; then
echo "false"
else
echo "true" echo "true"
else
echo "false"
fi fi
} }
@ -15,9 +15,9 @@ connected="$(is_connected)"
if [ "$1" = "toggle" ]; then if [ "$1" = "toggle" ]; then
if [ "$connected" = "false" ]; then if [ "$connected" = "false" ]; then
openvpn3 session-start --config "$config" > /dev/null sudo wg-quick up "$config" > /dev/null
else else
openvpn3 session-manage --disconnect --config "$config" > /dev/null sudo wg-quick down "$config" > /dev/null
fi fi
eww update vpn_status="{\"connected\": $(is_connected)}" eww update vpn_status="{\"connected\": $(is_connected)}"
exit 0 exit 0