45 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			45 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
| #!/bin/bash
 | |
| ########################################################
 | |
| ######################################################## 
 | |
| # 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"
 | |
| 
 | |
| WG_WDIR="/home/$USER/.config/wg_nmcli/"
 | |
| # Pfad wg Icons
 | |
| WG_PIC="/home/$USER/.icons/"
 | |
| # Wireguard TUNNEL auslesen mit grep nur Wireguard zeigen 
 | |
| #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) ) 
 | |
|   #echo ${lines[0]} #Damit wird der Inhalt ausgelesen. (Index angeben)
 | |
|   VALUE=$"*_*"
 | |
|     for VALUE in "${lines[@]}"
 | |
|     do 
 | |
|       # 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)
 | |
|           then 
 | |
|               yad --image-on-top --image=${WG_PIC}wg-info.png \
 | |
|                   --undecorated --borders=8 --skip-taskbar \
 | |
|                   --text-align=center --no-buttons \
 | |
|                   --timeout 2 --timeout-indicator=bottom \
 | |
|                   --text=$"<span color='#0fad0a'><b>$VALUE </b></span><span>   <b>disconnected</b></span>"
 | |
|       fi
 | |
|     done 
 | |
|     IFS=$'\n' lines=( $(cat ${WG_WDIR}for-kill_pid.txt) )
 | |
|     kill $lines
 | |
|     #test |