2023-11-19 11:15:52 +01:00
|
|
|
#!/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"
|
|
|
|
|
|
|
|
############################################################################################################
|
|
|
|
############################################################################################################
|
|
|
|
|
|
|
|
# wg_workdir Arbeitsverzeichnis wg
|
|
|
|
WG_WDIR="/home/$USER/.config/wg_nmcli/"
|
|
|
|
# Pfad wg Icons
|
|
|
|
WG_PIC="/home/$USER/.icons/"
|
2023-11-19 18:08:47 +01:00
|
|
|
IFS=$'\n' WG_START=( $(cat ${WG_WDIR}onstart.txt) )
|
|
|
|
nmcli connection up "$WG_START"
|
|
|
|
nmcli connection show --active | grep -iPo "(.*)(wireguard)" | sed 's/ .*//' &> ${WG_WDIR}onstart.txt
|
|
|
|
ACTIVE=$(nmcli connection show --active | grep -iPo "(.*)(wireguard)" | sed 's/ .*//')
|
2023-11-19 11:15:52 +01:00
|
|
|
|
|
|
|
case $LANG in
|
|
|
|
|
|
|
|
de_DE.UTF-8) OPEN=öffnen ;;
|
|
|
|
|
|
|
|
*) OPEN=open ;;
|
|
|
|
esac
|
|
|
|
yad --image-on-top --image=${WG_PIC}wg-vpn-info.png \
|
|
|
|
--undecorated --borders=8 --skip-taskbar \
|
|
|
|
--text-align=center --no-buttons --auto-close \
|
|
|
|
--timeout 1 \
|
|
|
|
--text=$"<span color='#0fad0a'><b>"$ACTIVE"</b></span> <span><b>powered</b></span>"
|
2023-11-19 18:08:47 +01:00
|
|
|
|
2023-11-19 11:15:52 +01:00
|
|
|
# autoconnect wird hier abgeschalten damit auch neu importierte nach einem Systemneustart nicht aktiv sind
|
|
|
|
IFS=$'\n' lines=( $(cat ${WG_WDIR}tunnel.txt) )
|
|
|
|
nmcli con mod "$lines" connection.autoconnect no
|
2023-11-19 16:04:54 +01:00
|
|
|
|
2023-11-19 15:59:41 +01:00
|
|
|
if grep 'TRUE TRUE\|TRUE FALSE' ${WG_WDIR}about.txt
|
|
|
|
then
|
|
|
|
chmod +x /home/"$USER"/.local/bin/wg_on_start
|
|
|
|
else
|
|
|
|
chmod -x /home/"$USER"/.local/bin/wg_on_start
|
|
|
|
fi
|
2023-11-19 18:08:47 +01:00
|
|
|
|
2023-11-19 11:15:52 +01:00
|
|
|
yad --notification \
|
|
|
|
--image="${WG_PIC}wg-vpn.png" \
|
|
|
|
--icon-size=32 --no-middle \
|
|
|
|
--text=$"$ACTIVE activ" \
|
|
|
|
--menu="Wire-G $OPEN!/sbin/wire_g
|
|
|
|
|$ACTIVE stop!/sbin/wg_stop" \
|
|
|
|
--command="menu" &
|
2023-11-19 18:08:47 +01:00
|
|
|
|
2023-11-19 11:15:52 +01:00
|
|
|
# Schreib die pid von Notify in
|
|
|
|
pid=$(ps aux | grep yad | grep -v grep | awk '{print $2}')
|
|
|
|
echo $pid > ${WG_WDIR}for-kill_pid.txt
|
|
|
|
IFS=$'\n' lines=( $(cat ${WG_WDIR}for-kill_pid.txt) )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|