test import double 2

This commit is contained in:
Désiré Werner Menrath 2023-11-17 21:00:29 +01:00
parent ea08fc954e
commit e483ddf816

59
wire_g
View File

@ -81,46 +81,45 @@ import_wg(){
--width=1200 --height=800 --no-klick \ --width=1200 --height=800 --no-klick \
--window-icon=${WG_PIC}wg-import.png \ --window-icon=${WG_PIC}wg-import.png \
--title=$"Wireguard .conf Select file") --title=$"Wireguard .conf Select file")
then then
IFS=$'\n' lines=( $(cat ${WG_WDIR}tunnel.txt) ) echo $WG_CONF > ${WG_WDIR}exist.txt
#echo ${lines[0]} #Damit wird der Inhalt ausgelesen. (Index angeben) if grep -f ${WG_WDIR}tunnel.txt ${WG_WDIR}exist.txt
for WG_CONF in "${lines[@]}" then
do
yad --image-on-top --image=${WG_PIC}wg-info.png \ yad --image-on-top --image=${WG_PIC}wg-info.png \
--text=$"Tunnel already exists!" \ --text=$"Tunnel already exists!" \
--text-align=center --no-buttons \ --text-align=center --button "OK" \
--borders=8 --undecorated \ --borders=8 --undecorated \
--timeout 3 --timeout-indicator=bottom --skip-taskbar --timeout-indicator=bottom --skip-taskbar
import_wg import_wg
done fi
else
case "$WG_CONF" in
*_*.conf) if grep -i 'PEER\|PublicKey' $WG_CONF > /dev/null && grep -i 'Interface\|PrivateKey' $WG_CONF > /dev/null case "$WG_CONF" in
*_*.conf) if grep -i 'PEER\|PublicKey' $WG_CONF > /dev/null && grep -i 'Interface\|PrivateKey' $WG_CONF > /dev/null
then
ACTIVE=$(nmcli connection show --active | grep -iPo "(.*)(wireguard)" | sed 's/ .*//')
if [[ -n $ACTIVE ]]
then then
ACTIVE=$(nmcli connection show --active | grep -iPo "(.*)(wireguard)" | sed 's/ .*//') wg_stop
if [[ -n $ACTIVE ]] nmcli connection import type wireguard file $WG_CONF &> ${WG_WDIR}.tmp.txt
then wait
wg_stop wg_notify
nmcli connection import type wireguard file $WG_CONF &> ${WG_WDIR}.tmp.txt else
wait kill $lines
wg_notify nmcli connection import type wireguard file $WG_CONF &> ${WG_WDIR}.tmp.txt
else wait
kill $lines wg_notify
nmcli connection import type wireguard file $WG_CONF &> ${WG_WDIR}.tmp.txt fi
wait fi ;;
wg_notify
fi
fi ;;
*) yad --image-on-top --image=${WG_PIC}wg-info.png --height=150 --width=240 \ *) yad --image-on-top --image=${WG_PIC}wg-info.png --height=150 --width=240 \
--text-align=center --undecorated --skip-taskbar \ --text-align=center --undecorated --skip-taskbar \
--borders=12 --button="OK" --buttons-layout=center --center \ --borders=12 --button="OK" --buttons-layout=center --center \
--text $"<b>Oh, something went wrong. No valid Wireguard file. </b> \n --text $"<b>Oh, something went wrong. No valid Wireguard file. </b> \n
<b>Here is an example:</b><span color='#0fad0a'><b> my_wireguard.conf</b></span>" <b>Here is an example:</b><span color='#0fad0a'><b> my_wireguard.conf</b></span>"
import_wg ;; import_wg ;;
esac esac
fi } fi }
# function end # function end