Wire-G/wg_stop

50 lines
2.4 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
############################################################################################################
############################################################################################################
WG_WDIR="/home/$USER/.config/wg_nmcli/"
WG_PIC="/home/$USER/.icons/"
#Dieser befehl ist notwendig da nach dem import (erster Start) gestartete Tunnel nicht in der .tunnel Datei stehen.
nmcli connection show | grep -iPo "(.*)(wireguard)" | sed 's/ .*//' > ${WG_WDIR}.tunnel.txt
#Damit wird der inhalt von /home/$USER/.config/wg_nmcli/.tunnel.txt in ein Array gespeichert
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)
VALUE=$"*_*"
for VALUE in "${lines[@]}"
2023-11-01 20:22:11 +01:00
do
2023-11-15 20:08:09 +01:00
# hier wird die Ausgabe von nmcli für die auswertung in die .stop.txt gespeichert
nmcli connection down "$VALUE" &> ${WG_WDIR}.stop.txt
if disable=$(grep -i 'deaktiviert\|deactivated' ${WG_WDIR}.stop.txt)
2023-11-15 12:38:16 +01:00
then
yad --image-on-top --image=${WG_PIC}wg-info.png \
--undecorated --borders=8 --skip-taskbar \
--text-align=center --no-buttons \
2023-11-15 17:56:10 +01:00
--timeout 2 --timeout-indicator=bottom \
2023-11-15 21:00:35 +01:00
--text=$"<span color='#0fad0a'><b>"$VALUE" Connection</b></span><span> <b>disconnected</b></span>"
2023-10-28 21:38:26 +02:00
fi
done
2023-11-15 20:39:59 +01:00
IFS=$'\n' lines=( $(awk '{print $2}' ${WG_WDIR}Notify_PID.txt) ) # Dies zeigt auf die richtige pid
kill -n "$lines" #> /dev/null 2>&1
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
############################################################################################################