50 lines
		
	
	
		
			2.4 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			50 lines
		
	
	
		
			2.4 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/"
 | 
						|
  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) ) 
 | 
						|
  #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" Connection</b></span><span> <b>disconnected</b></span>"
 | 
						|
      fi
 | 
						|
    done 
 | 
						|
  IFS=$'\n' lines=( $(awk '{print $2}' ${WG_WDIR}Notify_PID.txt) ) # Dies zeigt auf die richtige pid
 | 
						|
    kill $lines 
 | 
						|
 | 
						|
#################################   END   ##################################################################
 | 
						|
############################################################################################################ 
 | 
						|
 |