import-Dateiprüfung-eingebaut und fehler gefixt
This commit is contained in:
		
							
								
								
									
										69
									
								
								wire_g
									
									
									
									
									
								
							
							
						
						
									
										69
									
								
								wire_g
									
									
									
									
									
								
							@@ -19,7 +19,7 @@ export TEXTDOMAINDIR="/usr/share/locale"
 | 
			
		||||
 | 
			
		||||
############################################################################################################ 
 | 
			
		||||
############################################################################################################ 
 | 
			
		||||
version=3.0.9
 | 
			
		||||
version=3.1.0
 | 
			
		||||
# Angemeldeten Benutzer ermitteln
 | 
			
		||||
a_user=$(whoami)
 | 
			
		||||
# wg_workdir Arbeitsverzeichnis wg
 | 
			
		||||
@@ -35,8 +35,7 @@ tunnel=$(nmcli connection show | grep -iPo "(.*)(wireguard)" | sed 's/  .*//')
 | 
			
		||||
active=$(nmcli connection show --active | grep -iPo "(.*)(wireguard)" | sed 's/  .*//')
 | 
			
		||||
 | 
			
		||||
############################################################################################################ 
 | 
			
		||||
############################################################################################################ 
 | 
			
		||||
# funktion wg_notify
 | 
			
		||||
###############################wg_config.conf
 | 
			
		||||
 | 
			
		||||
wg_notify(){
 | 
			
		||||
    
 | 
			
		||||
@@ -74,36 +73,46 @@ import_wg(){
 | 
			
		||||
    a_user=$(whoami)
 | 
			
		||||
    wg_pic="/home/$a_user/.icons/"
 | 
			
		||||
    wg_wdir="/home/$a_user/.config/wg_nmcli/"
 | 
			
		||||
    if wgconf=$(yad --file --separator=" \n" \
 | 
			
		||||
    wgconf=$(yad --file --separator=" \n" \
 | 
			
		||||
                 --button="OK" --button=$"Cancel" \
 | 
			
		||||
                 --width=1200 --height=800 \
 | 
			
		||||
                 --window-icon=${wg_pic}wg-import.png \
 | 
			
		||||
                 --title=$"Wireguard .conf Select file")
 | 
			
		||||
        case $wgconf in 
 | 
			
		||||
            *.conf && *_*.conf) 
 | 
			
		||||
            active=$(nmcli connection show --active | grep -iPo "(.*)(wireguard)" | sed 's/  .*//')
 | 
			
		||||
            if [[ -n $active ]]
 | 
			
		||||
                then  
 | 
			
		||||
                    wg_stop
 | 
			
		||||
                    nmcli connection import type wireguard file $wgconf 2> ${wg_wdir}.tmp.txt
 | 
			
		||||
                    wg_notify
 | 
			
		||||
            elif [[ -z $active ]]
 | 
			
		||||
                then
 | 
			
		||||
                    nmcli connection import type wireguard file $wgconf 2> ${wg_wdir}.tmp.txt
 | 
			
		||||
                    wg_notify
 | 
			
		||||
            else
 | 
			
		||||
                    yad --text-align=center --button=$"OK" --title=$"Wireguard .conf Select file" \
 | 
			
		||||
                        --image-on-top --image=${wg_pic}wg-info.png \
 | 
			
		||||
                        --fixed --center --buttons-layout=center --borders=8 \
 | 
			
		||||
                        --text $"<b>Oh da ging etwas schief!</b> \n
 | 
			
		||||
<b>Keine gültige Wireguard Datei.</b> \n 
 | 
			
		||||
<b>Hier ein Beispiel:</b><span color='#0fad0a'><b>my_wireguard.conf</b></span> \n"  
 | 
			
		||||
                    import_wg
 | 
			
		||||
 | 
			
		||||
            fi
 | 
			
		||||
            ;;
 | 
			
		||||
        esac
 | 
			
		||||
    fi }
 | 
			
		||||
    case "$wgconf" in
 | 
			
		||||
 | 
			
		||||
        *_*.conf) if grep -i 'PEER\|PublicKey' wg_config.conf  > /dev/null &&  grep -i 'Interface\|PrivateKey' wg_config.conf > /dev/null
 | 
			
		||||
                    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
 | 
			
		||||
 | 
			
		||||
                        elif [[ -z $active ]]
 | 
			
		||||
                            then
 | 
			
		||||
                                nmcli connection import type wireguard file $wgconf &> ${wg_wdir}.tmp.txt
 | 
			
		||||
                                wg_notify
 | 
			
		||||
 | 
			
		||||
                        else 
 | 
			
		||||
                                yad --text-align=center --button=$"OK" --title=$"Wireguard .conf Select file" \
 | 
			
		||||
                                --image-on-top --image=${wg_pic}wg-info.png \
 | 
			
		||||
                                --fixed --center --buttons-layout=center --borders=8 \
 | 
			
		||||
                                --text $"<b>Oh da ging etwas schief.</b> \n
 | 
			
		||||
<b>Keine gültige Wireguard Datei.</b> \n 
 | 
			
		||||
<b>Hier ein Beispiel:</b><span color='#0fad0a'><b> my_wireguard.conf</b></span> \n"  
 | 
			
		||||
                    import_wg 
 | 
			
		||||
                        fi
 | 
			
		||||
                    fi ;;
 | 
			
		||||
        *) yad --text-align=center --button=$"OK" --title=$"Wireguard .conf Select file" \
 | 
			
		||||
                                --image-on-top --image=${wg_pic}wg-info.png \
 | 
			
		||||
                                --fixed --center --buttons-layout=center --borders=8 \
 | 
			
		||||
                                --text $"<b>Oh da ging etwas schief</b> \n
 | 
			
		||||
<b>Keine gültige Wireguard Datei.</b> \n 
 | 
			
		||||
<b>Hier ein Beispiel:</b><span color='#0fad0a'><b> my_wireguard.conf</b></span> \n" 
 | 
			
		||||
                    import_wg ;;
 | 
			
		||||
    esac }
 | 
			
		||||
export -f import_wg
 | 
			
		||||
 | 
			
		||||
# function end
 | 
			
		||||
@@ -185,7 +194,7 @@ export -f up_or_down
 | 
			
		||||
more(){ 
 | 
			
		||||
    a_user=$(whoami)
 | 
			
		||||
    wg_pic="/home/$a_user/.icons/"
 | 
			
		||||
    version=3.0.9
 | 
			
		||||
    version=3.1.0
 | 
			
		||||
    selection=$(yad --height=100 --width=80 \
 | 
			
		||||
                    --title="Wire-G" --center \
 | 
			
		||||
                    --fixed --borders=8 --close-on-unfocus \
 | 
			
		||||
@@ -197,7 +206,7 @@ more(){
 | 
			
		||||
                    --text=$"<span color='#626ff1'><b>Wire-G Author: Désiré Werner Menrath</b></span> \n 
 | 
			
		||||
<span color='#626ff1'><b>E-Mail: polunga40@unity-mail.de</b></span> \n
 | 
			
		||||
<span color='#626ff1'><b>At all tunnels, the auto start is disabled.</b></span> \n
 | 
			
		||||
<span color='#626ff1'><b>Version: $version </b></span> \n
 | 
			
		||||
<span color='#626ff1'><b>Version: "$version" </b></span> \n
 | 
			
		||||
<span color='#626ff1'><b>Use without warranty.</b></span> \n
 | 
			
		||||
<a href='https://git.lunix.dedyn.io/punix/Wire-G'>Download Wire-G </a> \n")
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user