import-Dateiprüfung-eingebaut und fehler gefixt

This commit is contained in:
Désiré Werner Menrath 2023-11-07 19:27:34 +01:00
parent c57279d868
commit ecd8990ebc

39
wire_g
View File

@ -19,7 +19,7 @@ export TEXTDOMAINDIR="/usr/share/locale"
############################################################################################################ ############################################################################################################
############################################################################################################ ############################################################################################################
version=3.0.9 version=3.1.0
# Angemeldeten Benutzer ermitteln # Angemeldeten Benutzer ermitteln
a_user=$(whoami) a_user=$(whoami)
# wg_workdir Arbeitsverzeichnis wg # 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/ .*//') active=$(nmcli connection show --active | grep -iPo "(.*)(wireguard)" | sed 's/ .*//')
############################################################################################################ ############################################################################################################
############################################################################################################ ###############################wg_config.conf
# funktion wg_notify
wg_notify(){ wg_notify(){
@ -74,36 +73,46 @@ import_wg(){
a_user=$(whoami) a_user=$(whoami)
wg_pic="/home/$a_user/.icons/" wg_pic="/home/$a_user/.icons/"
wg_wdir="/home/$a_user/.config/wg_nmcli/" wg_wdir="/home/$a_user/.config/wg_nmcli/"
if wgconf=$(yad --file --separator=" \n" \ wgconf=$(yad --file --separator=" \n" \
--button="OK" --button=$"Cancel" \ --button="OK" --button=$"Cancel" \
--width=1200 --height=800 \ --width=1200 --height=800 \
--window-icon=${wg_pic}wg-import.png \ --window-icon=${wg_pic}wg-import.png \
--title=$"Wireguard .conf Select file") --title=$"Wireguard .conf Select file")
case $wgconf in
*.conf && *_*.conf) 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/ .*//') active=$(nmcli connection show --active | grep -iPo "(.*)(wireguard)" | sed 's/ .*//')
if [[ -n $active ]] if [[ -n $active ]]
then then
wg_stop wg_stop
nmcli connection import type wireguard file $wgconf 2> ${wg_wdir}.tmp.txt nmcli connection import type wireguard file $wgconf &> ${wg_wdir}.tmp.txt
wg_notify wg_notify
elif [[ -z $active ]] elif [[ -z $active ]]
then then
nmcli connection import type wireguard file $wgconf 2> ${wg_wdir}.tmp.txt nmcli connection import type wireguard file $wgconf &> ${wg_wdir}.tmp.txt
wg_notify wg_notify
else else
yad --text-align=center --button=$"OK" --title=$"Wireguard .conf Select file" \ yad --text-align=center --button=$"OK" --title=$"Wireguard .conf Select file" \
--image-on-top --image=${wg_pic}wg-info.png \ --image-on-top --image=${wg_pic}wg-info.png \
--fixed --center --buttons-layout=center --borders=8 \ --fixed --center --buttons-layout=center --borders=8 \
--text $"<b>Oh da ging etwas schief!</b> \n --text $"<b>Oh da ging etwas schief.</b> \n
<b>Keine gültige Wireguard Datei.</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" <b>Hier ein Beispiel:</b><span color='#0fad0a'><b> my_wireguard.conf</b></span> \n"
import_wg import_wg
fi fi
;; fi ;;
esac *) yad --text-align=center --button=$"OK" --title=$"Wireguard .conf Select file" \
fi } --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 export -f import_wg
# function end # function end
@ -185,7 +194,7 @@ export -f up_or_down
more(){ more(){
a_user=$(whoami) a_user=$(whoami)
wg_pic="/home/$a_user/.icons/" wg_pic="/home/$a_user/.icons/"
version=3.0.9 version=3.1.0
selection=$(yad --height=100 --width=80 \ selection=$(yad --height=100 --width=80 \
--title="Wire-G" --center \ --title="Wire-G" --center \
--fixed --borders=8 --close-on-unfocus \ --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 --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>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>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 <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") <a href='https://git.lunix.dedyn.io/punix/Wire-G'>Download Wire-G </a> \n")