test 6 import
This commit is contained in:
parent
337d5abc7d
commit
75f64c648e
50
wire_g
50
wire_g
@ -73,39 +73,41 @@ 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/"
|
||||||
wgconf=$(yad --file --separator=" \n" \
|
if 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")
|
||||||
|
then
|
||||||
|
case "$wgconf" in
|
||||||
|
|
||||||
case "$wgconf" in
|
*_*.conf) if grep -i 'PEER\|PublicKey' $wgconf > /dev/null && grep -i 'Interface\|PrivateKey' $wgconf > /dev/null
|
||||||
|
|
||||||
*_*.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 ]]
|
|
||||||
then
|
then
|
||||||
wg_stop
|
active=$(nmcli connection show --active | grep -iPo "(.*)(wireguard)" | sed 's/ .*//')
|
||||||
nmcli connection import type wireguard file $wgconf &> ${wg_wdir}.tmp.txt
|
if [[ -n $active ]]
|
||||||
wg_notify
|
then
|
||||||
|
wg_stop
|
||||||
else
|
nmcli connection import type wireguard file $wgconf &> ${wg_wdir}.tmp.txt
|
||||||
nmcli connection import type wireguard file $wgconf &> ${wg_wdir}.tmp.txt
|
wg_notify
|
||||||
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" \
|
*) 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, something went wrong.</b> \n
|
--text $"<b>Oh, something went wrong.</b> \n
|
||||||
<b>No valid Wireguard file.</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"
|
<b>Here is an example:</b><span color='#0fad0a'><b> my_wireguard.conf</b></span> \n"
|
||||||
more ;;
|
import_wg ;;
|
||||||
esac
|
esac
|
||||||
}
|
else
|
||||||
|
exit 0
|
||||||
|
fi }
|
||||||
export -f import_wg
|
export -f import_wg
|
||||||
|
|
||||||
# function end
|
# function end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user