test 6 import

This commit is contained in:
Désiré Werner Menrath 2023-11-08 17:53:22 +01:00
parent 337d5abc7d
commit 75f64c648e

50
wire_g
View File

@ -73,39 +73,41 @@ import_wg(){
a_user=$(whoami)
wg_pic="/home/$a_user/.icons/"
wg_wdir="/home/$a_user/.config/wg_nmcli/"
wgconf=$(yad --file --separator=" \n" \
if 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")
then
case "$wgconf" in
case "$wgconf" in
*_*.conf) if grep -i 'PEER\|PublicKey' $wgconf > /dev/null && grep -i 'Interface\|PrivateKey' $wgconf > /dev/null
then
active=$(nmcli connection show --active | grep -iPo "(.*)(wireguard)" | sed 's/ .*//')
if [[ -n $active ]]
*_*.conf) if grep -i 'PEER\|PublicKey' $wgconf > /dev/null && grep -i 'Interface\|PrivateKey' $wgconf > /dev/null
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
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 ;;
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, something went wrong.</b> \n
*) 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, something went wrong.</b> \n
<b>No valid Wireguard file.</b> \n
<b>Here is an example:</b><span color='#0fad0a'><b> my_wireguard.conf</b></span> \n"
more ;;
esac
}
<b>Here is an example:</b><span color='#0fad0a'><b> my_wireguard.conf</b></span> \n"
import_wg ;;
esac
else
exit 0
fi }
export -f import_wg
# function end