variablen und ifs gequotet

This commit is contained in:
2023-11-01 11:11:18 +01:00
parent a1048076b5
commit e4b04c481b
2 changed files with 38 additions and 39 deletions

13
wg_stop
View File

@ -7,19 +7,18 @@
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
IFS=$'\n' lines=( $(cat ${wg_wdir}.tunnel.txt) )
IFS=$'\n' lines=( "$(cat "${wg_wdir}.tunnel.txt")" )
#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
nmcli connection down $wert &> ${wg_wdir}.stop.txt
disable=$(grep -i "deaktiviert" ${wg_wdir}.stop.txt)
if [ "$?" = "0" ]
then
notify-send --icon=${wg_pic}wg-stop.png "$wert Connection disconnected."
pkill yad
nmcli connection down "$wert" &> "${wg_wdir}.stop.txt"
if disable=$(grep -i '"deaktiviert"\|"disabled"' "${wg_wdir}.stop.txt")
then
notify-send --icon="${wg_pic}wg-stop.png" "$wert Connection disconnected."
pkill yad
fi
done