kleine fix

This commit is contained in:
Désiré Werner Menrath 2023-11-07 19:47:05 +01:00
parent ecd8990ebc
commit b658792c9a

33
wire_g
View File

@ -44,7 +44,7 @@ wg_notify(){
wg_pic="/home/$a_user/.icons/" wg_pic="/home/$a_user/.icons/"
notify-send --icon=${wg_pic}wg-vpn.png $"$active powered" notify-send --icon=${wg_pic}wg-vpn.png $"$active powered"
# autoconnect wird hier abgeschalten damit auch neu importierte nach einem Systemneustart nicht aktiv sind # autoconnect wird hier abgeschalten damit auch neu importierte nach einem Systemneustart nicht aktiv sind
nmcli con mod $active connection.autoconnect no nmcli con mod "$active" connection.autoconnect no
# ab hier beginnt yad notify # ab hier beginnt yad notify
#Pipe erstellen #Pipe erstellen
PIPE="$HOME/.pipe.tmp" PIPE="$HOME/.pipe.tmp"
@ -81,18 +81,18 @@ import_wg(){
case "$wgconf" in case "$wgconf" in
*_*.conf) if grep -i 'PEER\|PublicKey' wg_config.conf > /dev/null && grep -i 'Interface\|PrivateKey' wg_config.conf > /dev/null *_*.conf) if grep -i 'PEER\|PublicKey' "$wgconf" > /dev/null && grep -i 'Interface\|PrivateKey' "$wgconf" > /dev/null
then 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 &> ${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 &> ${wg_wdir}.tmp.txt nmcli connection import type wireguard file "$wgconf" &> ${wg_wdir}.tmp.txt
wg_notify wg_notify
else else
@ -134,20 +134,19 @@ remove(){
--fixed --buttons-layout=center --separator="" \ --fixed --buttons-layout=center --separator="" \
--button=$"OK" --button=$"Cancel" \ --button=$"OK" --button=$"Cancel" \
--borders=8 --image-on-top --image=${wg_pic}wg-active.png \ --borders=8 --image-on-top --image=${wg_pic}wg-active.png \
--column=$"Delete" $tunnel \ --column=$"Delete" "$tunnel" \
--text=$"<b>Activ Tunnel: </b> <span color='#0fad0a'><b>$active</b></span> --text=$"<b>Activ Tunnel: </b> <span color='#0fad0a'><b>$active</b></span>
<b>----------------------------------------------------------------------------------</b> <b>----------------------------------------------------------------------------------</b>
<b>If no tunnels are listed,</b> <b>If no tunnels are listed,</b>
<b>so they have to import their tunnel beforehand.</b>") <b>so they have to import their tunnel beforehand.</b>")
then then
nmcli connection delete $selection &> ${wg_wdir}.tmp.txt nmcli connection delete "$selection" &> ${wg_wdir}.tmp.txt
success=$(grep -i 'erfolgreich gelöscht\|successfully deleted' ${wg_wdir}.tmp.txt) if success=$(grep -i 'erfolgreich gelöscht\|successfully deleted' ${wg_wdir}.tmp.txt)
if [ "$?" = "0" ]
then then
yad --window-icon=${wg_pic}wg-trash.png \ yad --window-icon=${wg_pic}wg-trash.png \
--image-on-top --image=${wg_pic}wg-info.png \ --image-on-top --image=${wg_pic}wg-info.png \
--text=$"Your tunnel $selection was successfully deleted." \ --text=$"Your tunnel "$selection" was successfully deleted." \
--text-align=center --button=$"OK" --title "Wire-G Trash" \ --text-align=center --button=$"OK" --title "Wire-G Trash" \
--fixed --center --buttons-layout=center --borders=8 --center --fixed --center --buttons-layout=center --borders=8 --center
else else
@ -157,7 +156,7 @@ remove(){
--text-align=center --button=$"OK" --title "Wire-G Trash" \ --text-align=center --button=$"OK" --title "Wire-G Trash" \
--fixed --center --buttons-layout=center --borders=8 --center --fixed --center --buttons-layout=center --borders=8 --center
fi fi
if [ $selection = $active ] if [ "$selection" = "$active" ]
then then
pkill wire_g pkill wire_g
pkill yad pkill yad
@ -222,7 +221,7 @@ connect(){
if success=$(grep -i 'erfolgreich aktiviert\|successfully activated' ${wg_wdir}.tmp.txt) if success=$(grep -i 'erfolgreich aktiviert\|successfully activated' ${wg_wdir}.tmp.txt)
then then
nmcli con mod $selection connection.autoconnect no nmcli con mod "$selection" connection.autoconnect no
wg_notify wg_notify
fi } fi }
@ -239,7 +238,7 @@ if selection=$(yad --no-click --list \
--button=$"More":"bash -c more" --button=$"Remove":"bash -c remove" --separator="" \ --button=$"More":"bash -c more" --button=$"Remove":"bash -c remove" --separator="" \
--window-icon=${wg_pic}wg-vpn.png \ --window-icon=${wg_pic}wg-vpn.png \
--borders=8 --image-on-top --image=${wg_pic}wg-active.png \ --borders=8 --image-on-top --image=${wg_pic}wg-active.png \
--column=$"Selection" $tunnel \ --column=$"Selection" "$tunnel" \
--text=$"<b>Activ Tunnel: </b> <span color='#0fad0a'><b>$active</b></span> --text=$"<b>Activ Tunnel: </b> <span color='#0fad0a'><b>$active</b></span>
<b>----------------------------------------------------------------------------------</b> <b>----------------------------------------------------------------------------------</b>
<b>If no tunnels are listed,</b> <b>If no tunnels are listed,</b>
@ -247,13 +246,13 @@ if selection=$(yad --no-click --list \
then then
if [[ -n $active ]] if [[ -n "$active" ]]
then then
wg_stop wg_stop
nmcli connection up $selection &> ${wg_wdir}.tmp.txt nmcli connection up "$selection" &> ${wg_wdir}.tmp.txt
connect connect
else else
nmcli connection up $selection &> ${wg_wdir}.tmp.txt nmcli connection up "$selection" &> ${wg_wdir}.tmp.txt
connect connect
fi fi
fi fi