wg_stop wieder als extra skript wegen Notify menü
This commit is contained in:
parent
0ba8f1d71a
commit
400c229bfc
@ -62,7 +62,7 @@ fi
|
|||||||
wait;
|
wait;
|
||||||
sudo mkdir -p /usr/share/icons/Arch-Symbole ; sudo cp icons/wg-vpn.png /usr/share/icons/Arch-Symbole/
|
sudo mkdir -p /usr/share/icons/Arch-Symbole ; sudo cp icons/wg-vpn.png /usr/share/icons/Arch-Symbole/
|
||||||
wait;
|
wait;
|
||||||
sudo cp wire_g /sbin/ ; sudo chmod +x /sbin/wire_g
|
sudo cp wire_g /sbin/ ; sudo chmod +x /sbin/wire_g ; sudo cp wg_stop /sbin/ ; sudo chmod +x /sbin/wg_stop
|
||||||
wait; sudo cp Wire-G.desktop /usr/share/applications/
|
wait; sudo cp Wire-G.desktop /usr/share/applications/
|
||||||
echo
|
echo
|
||||||
case $LANG in
|
case $LANG in
|
||||||
|
@ -15,7 +15,7 @@ rm -f /home/"$USER"/.icons/wg-active.png wg-stop.png wg-vpn.png wg-import.png wg
|
|||||||
wait;
|
wait;
|
||||||
rm -r /home/"$USER"/.config/wg_nmcli
|
rm -r /home/"$USER"/.config/wg_nmcli
|
||||||
wait;
|
wait;
|
||||||
sudo rm /usr/share/icons/Arch-Symbole/wg-vpn.png ; sudo rm /sbin/wire_g
|
sudo rm /usr/share/icons/Arch-Symbole/wg-vpn.png ; sudo rm /sbin/wire_g ; sudo rm /sbin/wg_stop
|
||||||
wait;
|
wait;
|
||||||
sudo rm /usr/share/applications/Wire-G.desktop ; sudo rm /usr/share/locale/de/LC_MESSAGES/wire-g.mo
|
sudo rm /usr/share/applications/Wire-G.desktop ; sudo rm /usr/share/locale/de/LC_MESSAGES/wire-g.mo
|
||||||
echo
|
echo
|
||||||
|
40
wg_stop
Executable file
40
wg_stop
Executable file
@ -0,0 +1,40 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
########################################################
|
||||||
|
########################################################
|
||||||
|
# Wire-G App for simple management a Wireguard TUNNEL ##
|
||||||
|
# Author: Désiré Werner Menrath ##
|
||||||
|
# Email: polunga40@unity-mail.de ##
|
||||||
|
# Translate German to English with LibreTranslate ##
|
||||||
|
# Translatefiles edit with Poedit ##
|
||||||
|
# Use without warranty! ##
|
||||||
|
########################################################
|
||||||
|
########################################################
|
||||||
|
|
||||||
|
Encoding=UTF-8
|
||||||
|
|
||||||
|
# i18n - Internationalization - Internationalisierung
|
||||||
|
|
||||||
|
export TEXTDOMAIN=wire-g
|
||||||
|
export TEXTDOMAINDIR="/usr/share/locale"
|
||||||
|
|
||||||
|
#Dieser befehl ist notwendig da nach dem import (erster Start) gestartete Tunnel nicht in der .tunnel Datei stehen.
|
||||||
|
nmcli connection show | grep -iPo "(.*)(wireguard)" | sed 's/ .*//' > ${WG_WDIR}tunnel.txt
|
||||||
|
#Damit wird der inhalt von /home/$USER/.config/wg_nmcli/tunnel.txt in ein Array gespeichert
|
||||||
|
IFS=$'\n' lines=( $(cat ${WG_WDIR}tunnel.txt) )
|
||||||
|
#echo ${lines[0]} #Damit wird der Inhalt ausgelesen. (Index angeben)
|
||||||
|
VALUE=$"*_*"
|
||||||
|
for VALUE in "${lines[@]}"
|
||||||
|
do
|
||||||
|
# hier wird die Ausgabe von nmcli für die auswertung in die .stop.txt gespeichert
|
||||||
|
nmcli connection down "$VALUE" &> ${WG_WDIR}.stop.txt
|
||||||
|
if DISABLE=$(grep -i 'deaktiviert\|deactivated' ${WG_WDIR}.stop.txt)
|
||||||
|
then
|
||||||
|
yad --image-on-top --image=${WG_PIC}wg-info.png \
|
||||||
|
--undecorated --borders=8 --skip-taskbar \
|
||||||
|
--text-align=center --no-buttons \
|
||||||
|
--timeout 2 --timeout-indicator=bottom \
|
||||||
|
--text=$"<span color='#0fad0a'><b>"$VALUE" Connection</b></span><span> <b>disconnected</b></span>"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
IFS=$'\n' lines=( $(awk '{print $2}' ${WG_WDIR}for-kill_pid.txt) )
|
||||||
|
kill $lines
|
38
wire_g
38
wire_g
@ -33,41 +33,11 @@ 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/ .*//')
|
||||||
# Dies zeigt auf die richtige pid
|
# Dies zeigt auf die richtige pid
|
||||||
|
|
||||||
############################################################################################################
|
|
||||||
############################################################################################################
|
|
||||||
wg_stop(){
|
|
||||||
|
|
||||||
#Dieser befehl ist notwendig da nach dem import (erster Start) gestartete Tunnel nicht in der .tunnel Datei stehen.
|
|
||||||
nmcli connection show | grep -iPo "(.*)(wireguard)" | sed 's/ .*//' > ${WG_WDIR}tunnel.txt
|
|
||||||
#Damit wird der inhalt von /home/$USER/.config/wg_nmcli/tunnel.txt in ein Array gespeichert
|
|
||||||
IFS=$'\n' lines=( $(cat ${WG_WDIR}tunnel.txt) )
|
|
||||||
#echo ${lines[0]} #Damit wird der Inhalt ausgelesen. (Index angeben)
|
|
||||||
VALUE=$"*_*"
|
|
||||||
for VALUE in "${lines[@]}"
|
|
||||||
do
|
|
||||||
# hier wird die Ausgabe von nmcli für die auswertung in die .stop.txt gespeichert
|
|
||||||
nmcli connection down "$VALUE" &> ${WG_WDIR}.stop.txt
|
|
||||||
if DISABLE=$(grep -i 'deaktiviert\|deactivated' ${WG_WDIR}.stop.txt)
|
|
||||||
then
|
|
||||||
yad --image-on-top --image=${WG_PIC}wg-info.png \
|
|
||||||
--undecorated --borders=8 --skip-taskbar \
|
|
||||||
--text-align=center --no-buttons \
|
|
||||||
--timeout 2 --timeout-indicator=bottom \
|
|
||||||
--text=$"<span color='#0fad0a'><b>"$VALUE" Connection</b></span><span> <b>disconnected</b></span>"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
IFS=$'\n' lines=( $(awk '{print $2}' ${WG_WDIR}for-kill_pid.txt) )
|
|
||||||
kill $lines
|
|
||||||
}
|
|
||||||
|
|
||||||
export -f wg_stop
|
|
||||||
############################################################################################################
|
############################################################################################################
|
||||||
############################################################################################################
|
############################################################################################################
|
||||||
|
|
||||||
wg_notify(){
|
wg_notify(){
|
||||||
|
|
||||||
ACTIVE=$(nmcli connection show --active | grep -iPo "(.*)(wireguard)" | sed 's/ .*//')
|
|
||||||
WG_PIC="/home/$USER/.icons/"
|
|
||||||
case $LANG in
|
case $LANG in
|
||||||
|
|
||||||
de_DE.UTF-8) OPEN=öffnen ;;
|
de_DE.UTF-8) OPEN=öffnen ;;
|
||||||
@ -88,7 +58,7 @@ wg_notify(){
|
|||||||
--icon-size=32 --no-middle \
|
--icon-size=32 --no-middle \
|
||||||
--text=$"$ACTIVE activ" \
|
--text=$"$ACTIVE activ" \
|
||||||
--menu="Wire-G $OPEN!/sbin/wire_g
|
--menu="Wire-G $OPEN!/sbin/wire_g
|
||||||
|$ACTIVE stop!wg_stop" \
|
|$ACTIVE stop!/sbin/wg_stop" \
|
||||||
--command="menu" &
|
--command="menu" &
|
||||||
# Schreib die pid von Notify in
|
# Schreib die pid von Notify in
|
||||||
pid=$(ps aux | grep yad | grep -v grep | awk '{print $2}')
|
pid=$(ps aux | grep yad | grep -v grep | awk '{print $2}')
|
||||||
@ -106,8 +76,6 @@ wg_notify(){
|
|||||||
|
|
||||||
import_wg(){
|
import_wg(){
|
||||||
|
|
||||||
WG_PIC="/home/$USER/.icons/"
|
|
||||||
WG_WDIR="/home/$USER/.config/wg_nmcli/"
|
|
||||||
if WG_CONF=$(yad --file --separator=" \n" \
|
if WG_CONF=$(yad --file --separator=" \n" \
|
||||||
--button="OK" --button=$"Cancel" \
|
--button="OK" --button=$"Cancel" \
|
||||||
--width=1200 --height=800 --no-klick \
|
--width=1200 --height=800 --no-klick \
|
||||||
@ -124,10 +92,12 @@ import_wg(){
|
|||||||
then
|
then
|
||||||
wg_stop
|
wg_stop
|
||||||
nmcli connection import type wireguard file $WG_CONF &> ${WG_WDIR}.tmp.txt
|
nmcli connection import type wireguard file $WG_CONF &> ${WG_WDIR}.tmp.txt
|
||||||
|
wait
|
||||||
wg_notify
|
wg_notify
|
||||||
else
|
else
|
||||||
kill $lines
|
kill $lines
|
||||||
nmcli connection import type wireguard file $WG_CONF &> ${WG_WDIR}.tmp.txt
|
nmcli connection import type wireguard file $WG_CONF &> ${WG_WDIR}.tmp.txt
|
||||||
|
wait
|
||||||
wg_notify
|
wg_notify
|
||||||
fi
|
fi
|
||||||
fi ;;
|
fi ;;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user