Wire-G/wg_stop

30 lines
1.3 KiB
Plaintext
Raw Normal View History

2023-10-28 21:38:26 +02:00
#!/bin/bash
############################################################################################################
############################################################################################################
a_user=$(whoami)
wg_wdir="/home/$a_user/.config/wg_nmcli/"
wg_pic="/home/$a_user/.icons/"
#Damit wird der inhalt von /home/$a_user/.config/wg_nmcli/.tunnel.txt in ein Array gespeichert
2023-11-01 11:11:18 +01:00
IFS=$'\n' lines=( "$(cat "${wg_wdir}.tunnel.txt")" )
2023-10-28 21:38:26 +02:00
#echo ${lines[0]} #Damit wird der Inhalt ausgelesen. (Index angeben)
wert=$"*_*"
for wert in "${lines[@]}"
do
# rm /home/$a_user/.config/wg_nmcli/.tunnel.txt # falls Wireguard nicht richtig funktioniert hier die # wegnehmen
# hier wird die Ausgabe von nmcli für die auswertung in die .stop.txt gespeichert
2023-11-01 11:11:18 +01:00
nmcli connection down "$wert" &> "${wg_wdir}.stop.txt"
2023-11-01 11:51:29 +01:00
if disable=$(grep -i 'deaktiviert\|disabled' "${wg_wdir}.stop.txt")
2023-11-01 11:11:18 +01:00
then
notify-send --icon="${wg_pic}wg-stop.png" "$wert Connection disconnected."
pkill yad
2023-10-28 21:38:26 +02:00
fi
done
################################# ENDE #################################################################
############################################################################################################