diff --git a/installer1.0.5 b/installer1.0.5 new file mode 100644 index 0000000..16050ee --- /dev/null +++ b/installer1.0.5 @@ -0,0 +1,55 @@ +#!/bin/bash + +############################################################################################################ +############################################################################################################ + +# Angemeldeten Benutzer ermitteln +a_user=$(whoami) + +mkdir -p /home/"$a_user"/.icons ; cp icons/* /home/"$a_user"/.icons/ ; mkdir -p /home/"$a_user"/.config/wg_nmcli + +wait; +echo "Icons erfolgreich installiert" +wait; +# abfrage ob yad installiert ist, wenn nicht dann installiere automatisch yad. Nur Debian basierende Systeme! + + +if ! which yad >/dev/null + then + if grep -i 'mint\|debian\|ubuntu\|pop|' /etc/os-release > /dev/null 2>&1 + then + sudo apt install yad + + elif grep -i 'arch\|manjaro\|garuda\|endeavour|' /etc/os-release > /dev/null 2>&1 + then + sudo pacman -S yad + + elif grep -i 'fedora' /etc/os-release > /dev/null 2>&1 + then + sudo dnf install yad + + elif grep -i 'suse' /etc/os-release > /dev/null 2>&1 + then + clear + echo Achtung OpenSuse wird nicht offiziell unterstützt! + echo Sie können yad nachinstallieren und Wire-G dann verwenden, + echo oder den uninstaller ausführen um Wire-G zu entfernen + + else + echo Ihr system konnte nicht ermittelt werden. + echo Bitte installieren sie yad noch auf iher Distro nach. + echo Wire-G ist dann auch für ihr System bereit. + fi +fi + +wait; +sudo mkdir -p /usr/share/icons/Arch-Symbole ; sudo cp icons/wg-vpn.png /usr/share/icons/Arch-Symbole/ +wait; +sudo cp wire_g wg_stop /sbin/ ; sudo chmod +x /sbin/wire_g ; sudo chmod +x /sbin/wg_stop +wait; sudo cp Wire-G.desktop /usr/share/applications/ +echo +echo "Installation erfolgreich!" +read -n 1 -s -r -p "Zum Fenster schließen eine Taste drücken" +clear + +############################################ ENDE ######################################################### diff --git a/uninstaller1.0.0 b/uninstaller1.0.0 new file mode 100644 index 0000000..2773d3a --- /dev/null +++ b/uninstaller1.0.0 @@ -0,0 +1,18 @@ +#!/bin/bash + +a_user=$(whoami) +cd +rm -f /home/$a_user/.icons/wireguard-active.png wireguard-stop.png wireguard-vpn.png wg-import.png wg-trash.png wg-info.png +wait; +rm -r /home/$a_user/.config/wg_nmcli +wait; +sudo rm /usr/share/icons/Arch-Symbole/wireguard-vpn.png +wait; +sudo rm /sbin/wire_g ; sudo rm /sbin/wg_stop +wait; +sudo rm /usr/share/applications/Wire-G.desktop +echo +echo "deinstallation erfolgreich!" +read -n 1 -s -r -p "Zum Fenster schließen eine Taste drücken" +clear + diff --git a/wg_stop b/wg_stop new file mode 100644 index 0000000..e55ac02 --- /dev/null +++ b/wg_stop @@ -0,0 +1,29 @@ +#!/bin/bash + +############################################################################################################ +############################################################################################################ + + a_user=$(whoami) + wg_wdir="/home/$a_user/.config/wg_nmcli/" + wg_pic="/home/$a_user/.icons/" + #Damit wird der inhalt von /home/$a_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) + wert=$"*_*" + for wert in "${lines[@]}" + do + # rm /home/$a_user/.config/wg_nmcli/.tunnel.txt # falls Wireguard nicht richtig funktioniert hier die # wegnehmen + # hier wird die Ausgabe von nmcli für die auswertung in die .stop.txt gespeichert + nmcli connection down $wert &> ${wg_wdir}.stop.txt + disable=$(grep -i "deaktiviert" ${wg_wdir}.stop.txt) + if [ "$?" = "0" ] + then + notify-send --icon=${wg_pic}wg-stop.png "$wert Verbindung wurde getrennt." + pkill yad + fi + done + + +################################# ENDE ################################################################# +############################################################################################################ + diff --git a/wire_g b/wire_g new file mode 100644 index 0000000..072aae1 --- /dev/null +++ b/wire_g @@ -0,0 +1,159 @@ +#!/bin/bash + +############################################################################################################ +############################################################################################################ + +# Angemeldeten Benutzer ermitteln +a_user=$(whoami) +# wg_workdir Arbeitsverzeichnis wg +wg_wdir="/home/$a_user/.config/wg_nmcli/" +# Pfad wg Icons +wg_pic="/home/$a_user/.icons/" +# Wireguard tunnel auslesen mit grep nur Wireguard zeigen +# mit sed alles nach dem ersten Leerzeichen bis Zeilenende weggeschneiden und .tunnel.txt schreiben +nmcli connection show | grep -iPo "(.*)(wireguard)" | sed 's/ .*//' > ${wg_wdir}.tunnel.txt +# Variable der verfügbaren Tunnelanzeige für Yad +tunnel=$(nmcli connection show | grep -iPo "(.*)(wireguard)" | sed 's/ .*//') +# Variable der aktiven Tunnelanzeige für Yad +active=$(nmcli connection show --active | grep -iPo "(.*)(wireguard)" | sed 's/ .*//') + +############################################################################################################ +############################################################################################################ +# funktion wg_notify + +wg_notify(){ + + a_user=$(whoami) + active=$(nmcli connection show --active | grep -iPo "(.*)(wireguard)" | sed 's/ .*//') + wg_pic="/home/$a_user/.icons/" + notify-send --icon=${wg_pic}wg-vpn.png "$active eingeschaltet" + # autoconnect wird hier abgeschalten damit auch neu importierte nach einem Systemneustart nicht aktiv sind + nmcli con mod $active connection.autoconnect no + # ab hier beginnt yad notify + #Pipe erstellen + PIPE="$HOME/.pipe.tmp" + rm $PIPE + mkfifo $PIPE + exec 3<> $PIPE + #Yad Dialog erstellen + yad --notification --listen --command=wire_g --icon-size=32 --no-middle <&3 & + #Menüeinträge definieren + echo "menu:\ + $active stop!/sbin/wg_stop| " >&3 + #Icon des Menübuttons definieren + echo "icon:${wg_pic}wg-vpn.png" >&3 + #Name des Menüs definieren + echo "tooltip:$active aktiv" >&3 + +} +export -f wg_notify + +# function end +############################################################################################################ +############################################################################################################ +# funktion wireguard import + +import_wg(){ + a_user=$(whoami) + wg_pic="/home/$a_user/.icons/" + wg_wdir="/home/$a_user/.config/wg_nmcli/" + wgconf=$(yad --file --separator=" \n" \ + --button="OK" --button="Abbrechen" \ + --width=1200 --height=800 \ + --window-icon=${wg_pic}wg-import.png \ + --title="Wireguard .conf Datei auswählen") + if [ "$?" = "0" ] + then + wg_stop + nmcli connection import type wireguard file $wgconf > ${wg_wdir}.tmp.txt + wg_notify + fi } +export -f import_wg + +# function end +############################################################################################################ +############################################################################################################ +# funktion wireguard remove + +remove(){ + a_user=$(whoami) + wg_pic="/home/$a_user/.icons/" + wg_wdir="/home/$a_user/.config/wg_nmcli/" + tunnel=$(nmcli connection show | grep -iPo "(.*)(wireguard)" | sed 's/ .*//') + nmcli connection show --active | grep -iPo "(.*)(wireguard)" | sed 's/ .*//' &> ${wg_wdir}.wg_noactive.txt + active=$(cat ${wg_wdir}.wg_noactive.txt) + + selection=$(yad --no-click --list --height=300 --width=60 \ + --title="Wire-G Trash" \ + --fixed --buttons-layout=center \ + --button="OK" --button="Abbrechen" \ + --separator="" --window-icon=${wg_pic}wg-trash.png \ + --borders=8 --column 'Löschen' $tunnel) + if [ "$?" = "0" ] + then + nmcli connection delete $selection &> ${wg_wdir}.tmp.txt + erfolg=$(grep -i "Verbindung erfolgreich gelöscht" ${wg_wdir}.tmp.txt) + if [ "$?" = "0" ] + then + yad --window-icon=${wg_pic}wg-trash.png \ + --image-on-top --image=${wg_pic}wg-info.png \ + --text="Oh etwas ging schief.\nBitte Tunnel im Networkmanager löschen." \ + --text-align=center --button="OK" --title "Wire-G Trash" \ + --fixed --center --buttons-layout=center --borders=8 --center + else + yad --window-icon=${wg_pic}wg-trash.png \ + --image-on-top --image=${wg_pic}wg-info.png \ + --text="Ihr Tunnel $selection wurde erfolgreich gelöscht.\n" \ + --text-align=center --button="OK" --title "Wire-G Trash" \ + --fixed --center --buttons-layout=center --borders=8 --center + fi + if [ $selection = $active ] + then + pkill wire_g + pkill yad + fi + fi } +export -f remove + +# function end +############################################################################################################ +############################################################################################################ +# funktion wireguard enable select Tunnel + +connect(){ + + erfolg=$(grep -i "Verbindung wurde erfolgreich aktiviert" ${wg_wdir}.tmp.txt) + if [ "$?" = "0" ] + then + nmcli con mod $selection connection.autoconnect no + wg_notify + fi } + +# function end +############################################################################################################ +############################################################################################################ # --text "Aktiver Tunnel: $active # mit gewünschtes wort wird fett geschrieben. +# hiermit wird die Farbe für Variable $active festgelegt mit fetter Schrift. + +selection=$(yad --no-click --list \ + --close-on-unfocus --tab=Löschen \ + --height=300 --width=60 --title="Wire-G" \ + --fixed --buttons-layout=center \ + --button="OK" --button="Abbrechen" \ + --button=Importieren:"bash -c import_wg" \ + --button=Entfernen:"bash -c remove" --separator="" \ + --window-icon=${wg_pic}wg-vpn.png \ + --borders=8 --image-on-top --image=${wg_pic}wg-active.png \ + --text "Aktiver Tunnel: $active +---------------------------------------------------------------------------------- +Sollten keine Tunnel aufgelistet sein, +so müssen sie ihren Tunnel zuvor importieren." \ + --column 'Auswahl' $tunnel) + if [ "$?" = "0" ] + then + wg_stop + nmcli connection up $selection &> ${wg_wdir}.tmp.txt + connect + fi + +############################################ ENDE ######################################################### + diff --git a/wireguard.desktop b/wireguard.desktop new file mode 100644 index 0000000..09fd69e --- /dev/null +++ b/wireguard.desktop @@ -0,0 +1,7 @@ +[Desktop Entry] +Type=Application +Name=Wire-G +Exec=/sbin/wire_g +Terminal=false +Categories=Internet;Browser; +Icon=/usr/share/icons/Arch-Symbole/wg-vpn.png