Bei import if -n $active hinzugefügt

funktionen lesbarkeit angepasst
This commit is contained in:
Désiré Werner Menrath 2023-10-30 19:44:47 +01:00
parent 5bebb7ccaf
commit 298f3998d3

13
wire_g
View File

@ -63,10 +63,17 @@ import_wg(){
--window-icon=${wg_pic}wg-import.png \ --window-icon=${wg_pic}wg-import.png \
--title="Wireguard .conf Datei auswählen") --title="Wireguard .conf Datei auswählen")
if [ "$?" = "0" ] if [ "$?" = "0" ]
then
active=$(nmcli connection show --active | grep -iPo "(.*)(wireguard)" | sed 's/ .*//')
if [ -n $active ]
then then
wg_stop wg_stop
nmcli connection import type wireguard file $wgconf > ${wg_wdir}.tmp.txt nmcli connection import type wireguard file $wgconf > ${wg_wdir}.tmp.txt
wg_notify wg_notify
else
nmcli connection import type wireguard file $wgconf > ${wg_wdir}.tmp.txt
wg_notify
fi
fi } fi }
export -f import_wg export -f import_wg
@ -136,7 +143,7 @@ more(){
--button=Importieren:"bash -c import_wg" \ --button=Importieren:"bash -c import_wg" \
--button="Wire-G Stop":"bash -c wg_stop" \ --button="Wire-G Stop":"bash -c wg_stop" \
--button="Abbrechen":1 \ --button="Abbrechen":1 \
--separator="" --window-icon=${wg_pic}wg-vpn.png ) --separator="" --window-icon=${wg_pic}wg-vpn.png)
} }
export -f more export -f more
# function end # function end
@ -171,7 +178,7 @@ selection=$(yad --no-click --list \
<b>Sollten keine Tunnel aufgelistet sein,</b> <b>Sollten keine Tunnel aufgelistet sein,</b>
<b>so müssen sie ihren Tunnel zuvor importieren.</b>" \ <b>so müssen sie ihren Tunnel zuvor importieren.</b>" \
--column 'Auswahl' $tunnel) --column 'Auswahl' $tunnel)
if [ "$?" = "0" ] if [ "$?" = "0" ]
then then
active=$(nmcli connection show --active | grep -iPo "(.*)(wireguard)" | sed 's/ .*//') active=$(nmcli connection show --active | grep -iPo "(.*)(wireguard)" | sed 's/ .*//')
if [ -n $active ] if [ -n $active ]
@ -183,7 +190,7 @@ selection=$(yad --no-click --list \
nmcli connection up $selection &> ${wg_wdir}.tmp.txt nmcli connection up $selection &> ${wg_wdir}.tmp.txt
connect connect
fi fi
fi fi
############################################ ENDE ######################################################### ############################################ ENDE #########################################################