Wire-G/wg_stop

44 lines
1.9 KiB
Plaintext
Raw Normal View History

2023-10-28 21:38:26 +02:00
#!/bin/bash
2023-11-01 18:05:46 +01:00
########################################################
########################################################
# Wire-G App for simple management a Wireguard Tunnel ##
# Author: Désiré Werner Menrath ##
# Email: polunga40@unity-mail.de ##
# Translate German to English with LibreTranslate ##
# Translatefiles edit with Poedit ##
# Use without warranty! ##
########################################################
########################################################
Encoding=UTF-8
# i18n - Internationalization - Internationalisierung
export textdomain=wire-g
export textdomaindir="/usr/share/locale"
2023-10-28 21:38:26 +02:00
############################################################################################################
############################################################################################################
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 16:23:03 +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[@]}"
2023-11-01 20:22:11 +01:00
do
2023-10-28 21:38:26 +02:00
# 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\|deactivated' ${wg_wdir}.stop.txt)
2023-11-01 11:11:18 +01:00
then
notify-send --icon=${wg_pic}wg-stop.png $"$wert Connection disconnected"
2023-10-28 21:38:26 +02:00
fi
done
pkill yad
2023-10-28 21:38:26 +02:00
2023-11-01 20:22:11 +01:00
################################# END ##################################################################
2023-10-28 21:38:26 +02:00
############################################################################################################