wg_stop wieder als extra skript wegen Notify menü
This commit is contained in:
38
wire_g
38
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=$"<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 ;;
|
||||
|
Reference in New Issue
Block a user