Bei import if -n $active hinzugefügt
funktionen lesbarkeit angepasst
This commit is contained in:
		
							
								
								
									
										101
									
								
								wire_g
									
									
									
									
									
								
							
							
						
						
									
										101
									
								
								wire_g
									
									
									
									
									
								
							| @@ -62,12 +62,19 @@ import_wg(){ | ||||
|                  --width=1200 --height=800 \ | ||||
|                  --window-icon=${wg_pic}wg-import.png \ | ||||
|                  --title="Wireguard .conf Datei auswählen") | ||||
|       if [ "$?" = "0" ] | ||||
|         then  | ||||
|         wg_stop        | ||||
|         nmcli connection import type wireguard file $wgconf > ${wg_wdir}.tmp.txt | ||||
|         wg_notify | ||||
|       fi } | ||||
|     if [ "$?" = "0" ] | ||||
|         then | ||||
|             active=$(nmcli connection show --active | grep -iPo "(.*)(wireguard)" | sed 's/  .*//') | ||||
|             if [ -n $active ] | ||||
|                 then | ||||
|                     wg_stop        | ||||
|                     nmcli connection import type wireguard file $wgconf > ${wg_wdir}.tmp.txt | ||||
|                     wg_notify | ||||
|             else | ||||
|                     nmcli connection import type wireguard file $wgconf > ${wg_wdir}.tmp.txt | ||||
|                     wg_notify | ||||
|             fi | ||||
|     fi } | ||||
| export -f import_wg | ||||
|  | ||||
| # function end | ||||
| @@ -89,29 +96,29 @@ remove(){ | ||||
|                     --button="OK" --button="Abbrechen" \ | ||||
|                     --separator="" --window-icon=${wg_pic}wg-trash.png \ | ||||
|                     --borders=8 --column 'Löschen' $tunnel) | ||||
|      if [ "$?" = "0" ] | ||||
|       then | ||||
|       nmcli connection delete $selection &> ${wg_wdir}.tmp.txt  | ||||
|       success=$(grep -i "erfolgreich gelöscht" ${wg_wdir}.tmp.txt) | ||||
|         if [ "$?" = "0" ] | ||||
|           then | ||||
|           yad --window-icon=${wg_pic}wg-trash.png \ | ||||
|               --image-on-top --image=${wg_pic}wg-info.png \ | ||||
|               --text="Ihr Tunnel $selection wurde erfolgreich gelöscht.\n" \ | ||||
|               --text-align=center --button="OK" --title "Wire-G Trash" \ | ||||
|               --fixed --center --buttons-layout=center --borders=8 --center | ||||
|         else  | ||||
|           yad --window-icon=${wg_pic}wg-trash.png \ | ||||
|               --image-on-top --image=${wg_pic}wg-info.png \ | ||||
|               --text="Oh etwas ging schief.\nBitte Tunnel im Networkmanager löschen." \ | ||||
|               --text-align=center --button="OK" --title "Wire-G Trash" \ | ||||
|               --fixed --center --buttons-layout=center --borders=8 --center  | ||||
|         fi  | ||||
|         if [ $selection = $active ] | ||||
|           then | ||||
|           pkill wire_g | ||||
|           pkill yad | ||||
|         fi | ||||
|     if [ "$?" = "0" ] | ||||
|         then | ||||
|             nmcli connection delete $selection &> ${wg_wdir}.tmp.txt  | ||||
|             success=$(grep -i "erfolgreich gelöscht" ${wg_wdir}.tmp.txt) | ||||
|             if [ "$?" = "0" ] | ||||
|                 then | ||||
|                     yad --window-icon=${wg_pic}wg-trash.png \ | ||||
|                         --image-on-top --image=${wg_pic}wg-info.png \ | ||||
|                         --text="Ihr Tunnel $selection wurde erfolgreich gelöscht.\n" \ | ||||
|                         --text-align=center --button="OK" --title "Wire-G Trash" \ | ||||
|                         --fixed --center --buttons-layout=center --borders=8 --center | ||||
|             else  | ||||
|                     yad --window-icon=${wg_pic}wg-trash.png \ | ||||
|                         --image-on-top --image=${wg_pic}wg-info.png \ | ||||
|                         --text="Oh etwas ging schief.\nBitte Tunnel im Networkmanager löschen." \ | ||||
|                         --text-align=center --button="OK" --title "Wire-G Trash" \ | ||||
|                         --fixed --center --buttons-layout=center --borders=8 --center  | ||||
|             fi  | ||||
|             if [ $selection = $active ] | ||||
|                 then | ||||
|                     pkill wire_g | ||||
|                     pkill yad | ||||
|             fi | ||||
|      fi }  | ||||
| export -f remove | ||||
|   | ||||
| @@ -136,7 +143,7 @@ more(){ | ||||
|                     --button=Importieren:"bash -c import_wg" \ | ||||
|                     --button="Wire-G Stop":"bash -c wg_stop" \ | ||||
|                     --button="Abbrechen":1 \ | ||||
|                     --separator="" --window-icon=${wg_pic}wg-vpn.png ) | ||||
|                     --separator="" --window-icon=${wg_pic}wg-vpn.png) | ||||
| } | ||||
| export -f more | ||||
| # function end | ||||
| @@ -147,11 +154,11 @@ export -f more | ||||
| connect(){ | ||||
|  | ||||
|     success=$(grep -i "erfolgreich aktiviert" ${wg_wdir}.tmp.txt) | ||||
|       if [ "$?" = "0" ] | ||||
|     if [ "$?" = "0" ] | ||||
|         then | ||||
|         nmcli con mod $selection connection.autoconnect no  | ||||
|         wg_notify     | ||||
|       fi } | ||||
|             nmcli con mod $selection connection.autoconnect no  | ||||
|             wg_notify     | ||||
|     fi } | ||||
|  | ||||
| # function end | ||||
| ############################################################################################################  | ||||
| @@ -171,19 +178,19 @@ selection=$(yad --no-click --list \ | ||||
| <b>Sollten keine Tunnel aufgelistet sein,</b>  | ||||
| <b>so müssen sie ihren Tunnel zuvor importieren.</b>" \ | ||||
|                 --column 'Auswahl' $tunnel)    | ||||
|     if [ "$?" = "0" ] | ||||
|       then  | ||||
|       active=$(nmcli connection show --active | grep -iPo "(.*)(wireguard)" | sed 's/  .*//') | ||||
|       if [ -n $active ] | ||||
|       then | ||||
|       nmcli connection up $selection &> ${wg_wdir}.tmp.txt | ||||
|       connect | ||||
|       else | ||||
|       wg_stop | ||||
|       nmcli connection up $selection &> ${wg_wdir}.tmp.txt | ||||
|       connect | ||||
|       fi | ||||
|     fi | ||||
| if [ "$?" = "0" ] | ||||
|     then  | ||||
|         active=$(nmcli connection show --active | grep -iPo "(.*)(wireguard)" | sed 's/  .*//') | ||||
|         if [ -n $active ] | ||||
|             then | ||||
|                 nmcli connection up $selection &> ${wg_wdir}.tmp.txt | ||||
|                 connect | ||||
|         else | ||||
|                 wg_stop | ||||
|                 nmcli connection up $selection &> ${wg_wdir}.tmp.txt | ||||
|                 connect | ||||
|         fi | ||||
| fi | ||||
|  | ||||
| ############################################  ENDE  ######################################################### | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user