wg_stop wieder als extra skript wegen Notify menü

This commit is contained in:
Désiré Werner Menrath 2023-11-16 20:08:18 +01:00
parent 0ba8f1d71a
commit 400c229bfc
4 changed files with 46 additions and 36 deletions

View File

@ -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

View File

@ -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

40
wg_stop Executable file
View File

@ -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=$"<span color='#0fad0a'><b>"$VALUE" Connection</b></span><span> <b>disconnected</b></span>"
fi
done
IFS=$'\n' lines=( $(awk '{print $2}' ${WG_WDIR}for-kill_pid.txt) )
kill $lines

36
wire_g
View File

@ -35,39 +35,9 @@ ACTIVE=$(nmcli connection show --active | grep -iPo "(.*)(wireguard)" | sed 's/
############################################################################################################
############################################################################################################
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=$"<span color='#0fad0a'><b>"$VALUE" Connection</b></span><span> <b>disconnected</b></span>"
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 ;;