From 400c229bfc3ac19e89833b6150ad20be34b249fe Mon Sep 17 00:00:00 2001 From: punix Date: Thu, 16 Nov 2023 20:08:18 +0100 Subject: [PATCH] =?UTF-8?q?wg=5Fstop=20wieder=20als=20extra=20skript=20weg?= =?UTF-8?q?en=20Notify=20men=C3=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- installer1.0.5 | 2 +- uninstaller1.0.0 | 2 +- wg_stop | 40 ++++++++++++++++++++++++++++++++++++++++ wire_g | 38 ++++---------------------------------- 4 files changed, 46 insertions(+), 36 deletions(-) create mode 100755 wg_stop diff --git a/installer1.0.5 b/installer1.0.5 index 6da81bf..3fbe588 100755 --- a/installer1.0.5 +++ b/installer1.0.5 @@ -62,7 +62,7 @@ fi wait; sudo mkdir -p /usr/share/icons/Arch-Symbole ; sudo cp icons/wg-vpn.png /usr/share/icons/Arch-Symbole/ wait; -sudo cp wire_g /sbin/ ; sudo chmod +x /sbin/wire_g +sudo cp wire_g /sbin/ ; sudo chmod +x /sbin/wire_g ; sudo cp wg_stop /sbin/ ; sudo chmod +x /sbin/wg_stop wait; sudo cp Wire-G.desktop /usr/share/applications/ echo case $LANG in diff --git a/uninstaller1.0.0 b/uninstaller1.0.0 index 2fcef88..0d15eec 100755 --- a/uninstaller1.0.0 +++ b/uninstaller1.0.0 @@ -15,7 +15,7 @@ rm -f /home/"$USER"/.icons/wg-active.png wg-stop.png wg-vpn.png wg-import.png wg wait; rm -r /home/"$USER"/.config/wg_nmcli wait; -sudo rm /usr/share/icons/Arch-Symbole/wg-vpn.png ; sudo rm /sbin/wire_g +sudo rm /usr/share/icons/Arch-Symbole/wg-vpn.png ; sudo rm /sbin/wire_g ; sudo rm /sbin/wg_stop wait; sudo rm /usr/share/applications/Wire-G.desktop ; sudo rm /usr/share/locale/de/LC_MESSAGES/wire-g.mo echo diff --git a/wg_stop b/wg_stop new file mode 100755 index 0000000..d5feb72 --- /dev/null +++ b/wg_stop @@ -0,0 +1,40 @@ +#!/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" + +#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=$""$VALUE" Connection disconnected" + fi + done + IFS=$'\n' lines=( $(awk '{print $2}' ${WG_WDIR}for-kill_pid.txt) ) + kill $lines \ No newline at end of file diff --git a/wire_g b/wire_g index 2b6fb6b..ca7c488 100755 --- a/wire_g +++ b/wire_g @@ -33,41 +33,11 @@ TUNNEL=$(nmcli connection show | grep -iPo "(.*)(wireguard)" | sed 's/ .*//') ACTIVE=$(nmcli connection show --active | grep -iPo "(.*)(wireguard)" | sed 's/ .*//') # Dies zeigt auf die richtige pid -############################################################################################################ -############################################################################################################ -wg_stop(){ - - #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=$""$VALUE" Connection disconnected" - fi - done - IFS=$'\n' lines=( $(awk '{print $2}' ${WG_WDIR}for-kill_pid.txt) ) - kill $lines -} - - export -f wg_stop ############################################################################################################ ############################################################################################################ wg_notify(){ - - ACTIVE=$(nmcli connection show --active | grep -iPo "(.*)(wireguard)" | sed 's/ .*//') - WG_PIC="/home/$USER/.icons/" + case $LANG in de_DE.UTF-8) OPEN=öffnen ;; @@ -88,7 +58,7 @@ wg_notify(){ --icon-size=32 --no-middle \ --text=$"$ACTIVE activ" \ --menu="Wire-G $OPEN!/sbin/wire_g - |$ACTIVE stop!wg_stop" \ + |$ACTIVE stop!/sbin/wg_stop" \ --command="menu" & # Schreib die pid von Notify in pid=$(ps aux | grep yad | grep -v grep | awk '{print $2}') @@ -106,8 +76,6 @@ wg_notify(){ import_wg(){ - WG_PIC="/home/$USER/.icons/" - WG_WDIR="/home/$USER/.config/wg_nmcli/" if WG_CONF=$(yad --file --separator=" \n" \ --button="OK" --button=$"Cancel" \ --width=1200 --height=800 --no-klick \ @@ -124,10 +92,12 @@ import_wg(){ then wg_stop nmcli connection import type wireguard file $WG_CONF &> ${WG_WDIR}.tmp.txt + wait wg_notify else kill $lines nmcli connection import type wireguard file $WG_CONF &> ${WG_WDIR}.tmp.txt + wait wg_notify fi fi ;;