Wire-G/wg_stop
2023-11-01 11:11:18 +01:00

30 lines
1.3 KiB
Bash
Executable File

#!/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
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"
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
################################# ENDE #################################################################
############################################################################################################