Compare commits
14 Commits
b437ec4f4e
...
main
Author | SHA1 | Date | |
---|---|---|---|
a757d917b4 | |||
fd38c8b47d | |||
6aa1cfda8e | |||
![]() |
4dfd9e8ccf | ||
![]() |
c4339873f5 | ||
![]() |
3af7e917e2 | ||
49505ffa7e | |||
780622e6e9 | |||
06712dddc9 | |||
ccbc6a94da | |||
![]() |
b40a491e11 | ||
6f2c85c982 | |||
4c2eacb8ca | |||
03b4d45695 |
@@ -1,2 +1,2 @@
|
||||
#Name,E-Mail,Host,ServerFingerprint # Zeile muss gelöscht werden
|
||||
#Name,E-Mail,Host,ServerFingerprint
|
||||
bib,vorname.nachname@bib.de,vpn.bib.de,pin-sha265:asdasdasdasdasdasdasdasdasdasdadasd
|
||||
|
12
README.md
12
README.md
@@ -6,12 +6,12 @@ Voraussetzung dafür sind die Tools openconnect und xbar
|
||||
|
||||
Diese lassen sich einfach über [Homebrew](https://brew.sh/) installieren.
|
||||
|
||||
#### Installation des Tools (Skript)
|
||||
## Installation des Tools (Skript)
|
||||
```bash
|
||||
/bin/bash -c "$(curl -fsSL https://git.bib.de/ITS/OpenConnect_macOS_Bar/raw/branch/main/install.sh)"
|
||||
```
|
||||
|
||||
#### Installation in Einzelschritten
|
||||
## Manuelle Installation in Einzelschritten
|
||||
Zunächst Homebrew installieren, sofern noch nicht geschehen.
|
||||
|
||||
```zsh
|
||||
@@ -24,7 +24,6 @@ Danach kann man simple die benötigten Tools installieren.
|
||||
|
||||
```bash
|
||||
brew update && brew install openconnect swiftbar
|
||||
|
||||
```
|
||||
---
|
||||
|
||||
@@ -32,13 +31,13 @@ Nach der Installation laden wir das Skript und machen es ausführbar.
|
||||
|
||||
```bash
|
||||
# Ordner anlegen, falls noch nicht vorhanden und dann dorhin navigieren
|
||||
mkdir -p /Users/$USER/Library/Application\ Support/SwiftBar/plugins && cd $_
|
||||
mkdir -p "/Users/$USER/Library/SwiftBar/plugins" && cd $_
|
||||
# Skript laden und ausführbar machen
|
||||
wget https://git.bib.de/ITS/OpenConnect_macOS_Bar/raw/branch/main/bibVPN.sh
|
||||
chmod +x bibVPN.sh
|
||||
|
||||
# PluginFolder für SwiftBar setzen
|
||||
defaults write /Users/$USER/Library/Preferences/com.ameba.SwiftBar.plist PluginDirectory "/Users/$User/Library/Application Support/SwiftBar/plugins"
|
||||
defaults write /Users/$USER/Library/Preferences/com.ameba.SwiftBar.plist PluginDirectory "/Users/$USER/Library/SwiftBar/plugins"
|
||||
```
|
||||
|
||||
---
|
||||
@@ -57,3 +56,6 @@ Danach sollte in der Menüleiste das Tool auftauchen.
|
||||
```zsh
|
||||
open /Applications/SwiftBar.app
|
||||
```
|
||||
|
||||
Es sollte nun das Menüicon auftauchen.
|
||||

|
257
bibVPN.sh
257
bibVPN.sh
@@ -8,7 +8,7 @@
|
||||
#joesmith ALL=(ALL) NOPASSWD: /usr/bin/killall -2 openconnect
|
||||
|
||||
# <xbar.title>VPN Status</xbar.title>
|
||||
# <xbar.version>v1.2</xbar.version>
|
||||
# <xbar.version>v1.3</xbar.version>
|
||||
# <xbar.author>Thomas Schmauder</xbar.author>
|
||||
# <xbar.author.github>itssct</xbar.author.github>
|
||||
# <xbar.desc>Displays status of a VPN interface with option to connect/disconnect.</xbar.desc>
|
||||
@@ -23,29 +23,115 @@
|
||||
###################
|
||||
#### Variables ####
|
||||
###################
|
||||
VERSION=1.2.1
|
||||
VERSION='1.5.1'
|
||||
WORKDIR="/Users/$USER/.openconnect"
|
||||
mkdir -p $WORKDIR
|
||||
logfile="$WORKDIR/bibVPN.log"
|
||||
echo -e "\nStart: $(date)" >>$logfile
|
||||
echo "Run $0 $@" >> $logfile
|
||||
LOG="$WORKDIR/bibVPN.log"
|
||||
ERRORLOG="$WORKDIR/ERROR.log"
|
||||
echo -e "\nStart: $(date)" >>$LOG
|
||||
echo "Run $0 $@" >> $LOG
|
||||
PATH=$PATH:/usr/local/bin
|
||||
VPN_EXECUTABLE=$(which openconnect)
|
||||
OC_PIDFILE="$WORKDIR/vpn.bib.de.pid"
|
||||
SETTINGSFILE="$WORKDIR/settings.csv"
|
||||
SETTINGSFILE="$WORKDIR/settings.txt"
|
||||
ACCOUNTFILE="$WORKDIR/accounts.csv"
|
||||
VPN_USERNAME="$2"
|
||||
VPN_HOST="$3"
|
||||
|
||||
#### Settings ####
|
||||
SHOW_SETTINGS='ON'
|
||||
SHOW_ICONS='ON'
|
||||
SHOW_SETTINGS='true'
|
||||
SHOW_ICON='true'
|
||||
SHOW_COLOR='true'
|
||||
DEBUG_OUTPUT='false'
|
||||
NET_FILTER='inet 172.[123][0-9].1[67][80].'
|
||||
FONT=( 'size=14' 'font=UbuntuMono' )
|
||||
|
||||
###################
|
||||
#### Functions ####
|
||||
###################
|
||||
function saveSettings(){
|
||||
echo "Speichere die Einstellungen" >> $LOG
|
||||
echo "SHOW_SETTINGS='$SHOW_SETTINGS'
|
||||
SHOW_ICON='$SHOW_ICON'
|
||||
SHOW_COLOR='$SHOW_COLOR'
|
||||
DEBUG_OUTPUT=$DEBUG_OUTPUT" | tee $SETTINGSFILE
|
||||
|
||||
echo "Lade die Einstellungsdatei" >> $LOG
|
||||
source $SETTINGSFILE
|
||||
open swiftbar://refreshplugin?name=$(basename $0)
|
||||
}
|
||||
|
||||
function askFor(){
|
||||
osascript="$1 buttons {\"Cancel\",\"OK\"} default button {\"OK\"} cancel button \"Cancel\" with title \"Neuen User für das VPN anlegen\" with icon caution"
|
||||
#üecho $osascript >> $LOG
|
||||
results=$( /usr/bin/osascript -e "$osascript")
|
||||
if [[ $? != 0 ]]; then
|
||||
clmsg='display notification "" with title "OpenConnectVPN" subtitle "Beende mich" sound name "Submarine"'
|
||||
osascript -e "$clmsg"
|
||||
exit 2
|
||||
else
|
||||
#echo $results >> $LOG
|
||||
theButton=$( echo "$results" | /usr/bin/awk -F "button returned:|," '{print $2}' )
|
||||
theText=$( echo "$results" | /usr/bin/awk -F "text returned:" '{print $2}' )
|
||||
|
||||
if [[ $theButton == "OK" ]] ;then
|
||||
if [ -z $theText ];then
|
||||
echo "OK"
|
||||
else
|
||||
echo $theText
|
||||
fi
|
||||
elif [[ $theButton == "Cancel" ]] ; then
|
||||
clmsg='display notification "" with title "OpenConnectVPN" subtitle "Beende mich" sound name "Submarine"'
|
||||
osascript -e "$clmsg"
|
||||
break
|
||||
exit 2
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function showSettings()
|
||||
{
|
||||
echo '---'
|
||||
echo "Neues **VPN** Profil anlegen | shell='$0' param1=newuser terminal=false refresh=true md=true"
|
||||
if [[ $SHOW_SETTINGS == "true" ]]; then
|
||||
echo "---"
|
||||
echo "Settings"
|
||||
echo "--Icons verwenden | shell='$0' terminal=false param1=toggleIcon tooltip='Icon im Menü anzeigen oder Text' checked=$SHOW_ICON"
|
||||
echo "--Farbiges Icon/Schrift | shell='$0' terminal=false param1=toggleColor tooltip='Icon oder Schrift einfärben oder eintönig lassen' checked=$SHOW_COLOR"
|
||||
echo "---"
|
||||
echo "-- --- INFOS ---"
|
||||
echo "--**Logfile:** *${LOG}* | shell='$0' param1=openlog terminal=false refresh=true tooltip='Das Logfile öffnen' md=true"
|
||||
echo "--${SETTINGSFILE} | shell='$0' param1=openDIR terminal=false refresh=true tooltip='Ordner öffnen'"
|
||||
echo "--Script: $(basename -- "$0") Version: **v$VERSION** | href="https://git.bib.de/itssct/OpenFortiVPN_macOS" terminal=false refresh=true tooltip='Die Projektwebsite im Browser öffnen' md=true"
|
||||
if [[ $DEBUG_OUTPUT == 'true' ]] ; then
|
||||
echo "-- --- DEBUG ---"
|
||||
echo "--SHOW_ICON: $SHOW_ICON"
|
||||
echo "--SHOW_COLOR: $SHOW_COLOR"
|
||||
echo "--COLOR_CONNECTED: $COLOR_CONNECTED"
|
||||
echo "--COLOR_UNCONNECTED: $COLOR_UNCONNECTED"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
###################
|
||||
#### Prüfungen ####
|
||||
###################
|
||||
if [ -f $SETTINGSFILE ] ; then
|
||||
echo "Lade die Einstellungsdatei" >> $LOG
|
||||
source $SETTINGSFILE
|
||||
else
|
||||
saveSettings
|
||||
fi
|
||||
|
||||
if [ $SHOW_COLOR == 'true' ] ; then
|
||||
COLOR_CONNECTED='green'
|
||||
COLOR_UNCONNECTED='crimson'
|
||||
else
|
||||
COLOR_CONNECTED='none'
|
||||
COLOR_UNCONNECTED='none'
|
||||
fi
|
||||
|
||||
# A command that will result in your VPN password.
|
||||
GET_VPN_PASSWORD="security find-generic-password -g -a $VPN_USERNAME 2>&1 >/dev/null | cut -d'\"' -f2"
|
||||
GET_VPN_PASSWORD="security find-generic-password -w -l openconnect -a $VPN_USERNAME 2>&1"
|
||||
# Command to determine if VPN is connected or disconnected
|
||||
VPN_CONNECTED="ifconfig | egrep -A1 '$NET_FILTER' |cut -d' ' -f2"
|
||||
# Command to run to disconnect VPN
|
||||
@@ -54,53 +140,74 @@ VPN_DISCONNECT_CMD="sudo killall -2 openconnect"
|
||||
# Get IP of Current VPN Tunnel
|
||||
IP=$(ifconfig | egrep -A1 "$NET_FILTER" |cut -d' ' -f2)
|
||||
|
||||
###################
|
||||
#### Functions ####
|
||||
###################
|
||||
function askFor(){
|
||||
osascript="$1 buttons {\"Cancel\",\"OK\"} default button {\"OK\"} with title \"Neuen User für das VPN anlegen\""
|
||||
echo $osascript
|
||||
results=$( /usr/bin/osascript -e "$osascript")
|
||||
|
||||
theButton=$( echo "$results" | /usr/bin/awk -F "button returned:|," '{print $2}' )
|
||||
theText=$( echo "$results" | /usr/bin/awk -F "text returned:" '{print $2}' )
|
||||
|
||||
if [[ $theButton == "OK" ]] ;then
|
||||
echo $theText;
|
||||
fi
|
||||
}
|
||||
|
||||
function showSettings()
|
||||
{
|
||||
if [[ $SHOW_SETTINGS == "ON" ]]; then
|
||||
echo "---"
|
||||
echo "Settings"
|
||||
echo "--$SETTINGSFILE"
|
||||
echo "--Farbige Icons aus (not ready)"
|
||||
echo "--Neuen User anlegen| shell='$0' param1=newuser terminal=true refresh=true"
|
||||
echo "---"
|
||||
echo "--$(basename -- "$0") v$VERSION"
|
||||
fi
|
||||
}
|
||||
###################
|
||||
###### MAIN #######
|
||||
###################
|
||||
case "$1" in
|
||||
connect)
|
||||
rm -f $ERRORLOG
|
||||
echo "$GET_VPN_PASSWORD" >> $LOG
|
||||
VPN_PASSWORD=$(eval "$GET_VPN_PASSWORD")
|
||||
# Passwort checken
|
||||
#if [[ -z VPN_PASSWORD ]]; then VPN_PASSWORD=$(askFor 'display dialog "Es ist kein Passwort im Schlüsselbund vorhanden. Wie lautet das Passwort? " default answer "vpn.bib.de"'); fi
|
||||
#security add-generic-password -a $VPN_USERNAME -s openconnect -w $keychainPW
|
||||
VPN_EXECUTABLE_PARAMS="--servercert $4 --protocol=fortinet" # Optional
|
||||
if [[ $VPN_PASSWORD =~ 'item could not be found in the keychain.' ]] ; then
|
||||
echo "Es konnte kein Passwort für $VPN_USERNAME gefunden werden" >> $LOG
|
||||
NEW_VPN_PASSWORD=$(askFor 'display dialog "Es ist kein Passwort im Schlüsselbund vorhanden. Wie lautet das Passwort für '$VPN_USERNAME'? " default answer "Mein Passwort..." with hidden answer')
|
||||
if [[ $? != 0 ]]; then exit 2 ; fi # Beim Abbruch der Maske, gesamte Script beenden.
|
||||
#echo $VPN_PASSWORD
|
||||
VPN_PASSWORD=$NEW_VPN_PASSWORD
|
||||
#echo "security add-generic-password -a $VPN_USERNAME -s openconnect -w '$VPN_PASSWORD'" >> $LOG
|
||||
SAVE_PASSWORD=$(askFor 'display dialog "Soll das Passwort, dauerhaft im Schlüsselbund gespeichert werden? "')
|
||||
if [[ $SAVE_PASSWORD == "OK" ]]; then
|
||||
security add-generic-password -a $VPN_USERNAME -s openconnect -T /usr/bin/security -w "$NEW_VPN_PASSWORD"
|
||||
fi
|
||||
#else
|
||||
#echo "VPN PASSWORT: $VPN_PASSWORD" >> $LOG
|
||||
fi
|
||||
VPN_EXECUTABLE_PARAMS="--passwd-on-stdin --servercert $4 --protocol=fortinet --pid-file=$OC_PIDFILE --background" # Optional
|
||||
|
||||
# Verbindung aufbauen
|
||||
echo "echo <pseudeoPW> | sudo $VPN_EXECUTABLE $VPN_EXECUTABLE_PARAMS --user $VPN_USERNAME --passwd-on-stdin $VPN_HOST --pid-file=$OC_PIDFILE --background" > $logfile 2>&1
|
||||
echo "$VPN_PASSWORD" | sudo $VPN_EXECUTABLE $VPN_EXECUTABLE_PARAMS --user $VPN_USERNAME --passwd-on-stdin $VPN_HOST --pid-file=$OC_PIDFILE --background > $logfile 2>&1
|
||||
echo "<pseudoPasswort>| sudo $VPN_EXECUTABLE $VPN_EXECUTABLE_PARAMS --user $VPN_USERNAME $VPN_HOST" >> $LOG
|
||||
echo "$VPN_PASSWORD" | sudo $VPN_EXECUTABLE $VPN_EXECUTABLE_PARAMS --user $VPN_USERNAME $VPN_HOST 2> $ERRORLOG 1>> $LOG
|
||||
if [[ $? != 0 ]]; then
|
||||
if [ -f $ERRORLOG ] ; then
|
||||
cat $ERRORLOG >> $LOG
|
||||
if grep -q "None of the 1 fingerprint(s) specified via --servercert match server's certificate:" $ERRORLOG ; then
|
||||
newServerCert=$(grep -o 'pin-.*=$' $ERRORLOG)
|
||||
echo "Das Servercert ist nicht aktuell. Dieses muss aktualisiert werden. (ALT: $4 | NEU: $newServerCert)" >> $LOG
|
||||
dialogCert=$(osascript -e "display alert \"Das Servercert ist nicht aktuell. \nSoll dieses aktualisiert werden?\n\nAlt : \n$4\n\nNeu : \n$newServerCert\" buttons {\"Nein\", \"Ja\"}")
|
||||
theButton=$( echo "$dialogCert" | /usr/bin/awk -F "button returned:|," '{print $2}' )
|
||||
if [[ $theButton == "Ja" ]] ;then
|
||||
echo "Ändere das Servercert" >> $LOG
|
||||
# sed mit | statt / , da im String auch Slashes vorhanden sein können.
|
||||
echo "sed -i '' -e \"s|$4|$newServerCert|g\" $ACCOUNTFILE" >> $LOG
|
||||
sed -i '' -e "s|$4|$newServerCert|g" $ACCOUNTFILE
|
||||
if [[ $? = 0 ]]; then
|
||||
osascript -e 'display alert "Erfolgreich geändert. Bitte die Verbindung erneut aufbauen."'
|
||||
fi
|
||||
else
|
||||
echo "Wie du willst. Das Servercert wird nicht geändert." >> $LOG
|
||||
fi
|
||||
elif grep -q "nodename nor servname provided, or not known" $ERRORLOG; then
|
||||
echo "Verbindungsaufbau fehlgeschlagen. $VPN_HOST kann nicht aufgelöst werden." >> $LOG
|
||||
osascript -e "display notification \"Verbindungsaufbau fehlgeschlagen. $VPN_HOST kann nicht aufgelöst werden.\" with title \"OpenConnectVPN\" subtitle \"Schade\" sound name \"Brise\""
|
||||
fi
|
||||
else
|
||||
osascript -e 'display notification "Verbindungsaufbau fehlgeschlagen. Bitte im Log prüfen, was die Ursache ist." with title "OpenConnectVPN" subtitle "Schade" sound name "Brise"'
|
||||
fi
|
||||
exit
|
||||
fi
|
||||
IP=$(ifconfig | egrep -A1 "$NET_FILTER" |cut -d' ' -f2)
|
||||
while [ -z $IP ]; do echo "noch keine IP" ; sleep 0.5 ; IP=$(ifconfig | egrep -A1 "$NET_FILTER"|cut -d' ' -f2) ; done
|
||||
msg='display notification "Erfolgreich verbunden \nConnected User: '$VPN_USERNAME'" with title "OpenFortiVPN" subtitle "Deine IP lautet: '$IP'" sound name "Brise"'
|
||||
errmsg='display notification "Verbindungsversuch nicht erfolgreich" with title "OpenFortiVPN" subtitle "Schade" sound name "Brise"'
|
||||
if [[ $IP =~ 172 ]] ; then osascript -e "$msg" ; else osascript -e "$errmsg" ; fi
|
||||
ii=0
|
||||
while [ -z $IP ] && [[ $ii != 20 ]]; do echo "noch keine IP" ; sleep 0.5 ; IP=$(ifconfig | egrep -A1 "$NET_FILTER"|cut -d' ' -f2) ; ((ii++)) ; done
|
||||
msg='display notification "Erfolgreich verbunden \nConnected User: '$VPN_USERNAME'" with title "OpenConnectVPN" subtitle "Deine IP lautet: '$IP'" sound name "Brise"'
|
||||
errmsg='display notification "Verbindungsversuch nicht erfolgreich. Vermutlich ist das Passwort falsch." with title "OpenConnectVPN" subtitle "Schade" sound name "Brise"'
|
||||
if [[ $IP =~ 172 ]] ; then
|
||||
osascript -e "$msg" ;
|
||||
else
|
||||
osascript -e "$errmsg"
|
||||
echo "Vermutlich ist das Passwort falsch. Es konnte keine Verbindung hergestellt werden." >> $LOG
|
||||
exit 5 ;
|
||||
fi
|
||||
# Wait for connection so menu item refreshes instantly
|
||||
until eval "$VPN_CONNECTED"; do sleep 1; done
|
||||
;;
|
||||
@@ -108,43 +215,71 @@ case "$1" in
|
||||
eval "$VPN_DISCONNECT_CMD"
|
||||
# Wait for disconnection so menu item refreshes instantly
|
||||
until [ -z "$(eval "$VPN_CONNECTED")" ]; do sleep 1; eval "$VPN_CONNECTED" ;done
|
||||
osascript -e 'display notification "VPN Tunnel erfolgreich geschlossen" with title "OpenFortiVPN" subtitle "Mach Feierabend" sound name "Submarine"'
|
||||
osascript -e 'display notification "VPN Tunnel erfolgreich geschlossen" with title "OpenConnectVPN" subtitle "Mach Feierabend" sound name "Submarine"'
|
||||
;;
|
||||
newuser)
|
||||
echo "Sie wollen einen weiteren Benutzer für das VPN anlegen. Geben Sie dazu die folgenden Dinge ein."
|
||||
askFor 'display dialog "Sie wollen einen weiteren Benutzer für das VPN anlegen. Geben Sie dazu die folgenden Dinge ein."'
|
||||
NEW_VPN_NAME=$(askFor 'display dialog "Wie soll die neue Verbindung heißen?" default answer "bib | eduUP | FHDW"' )
|
||||
NEW_VPN_USERNAME=$(askFor 'display dialog "Wie lautet die E-Mail des Benutzers, der zum Verbinden verwendet werden soll?" default answer "vorname.nachname@bib.de"' )
|
||||
NEW_VPN_HOST=$(askFor 'display dialog "Wie lautet der Servername?" default answer "vpn.bib.de"')
|
||||
#echo "Sie wollen einen weiteren Benutzer für das VPN anlegen. Geben Sie dazu die folgenden Dinge ein."
|
||||
askFor 'display dialog "Sie wollen einen weiteren Benutzer für das VPN anlegen. Geben Sie dazu die benötigten Daten an."'
|
||||
NEW_VPN_NAME=$(askFor 'display dialog "Wie soll die neue Verbindung heißen?" default answer "bib | eduUP | FHDW"' ); if [[ $? != 0 ]]; then exit 2 ; fi # Beim Abbruch der Maske, gesamte Script beenden.
|
||||
NEW_VPN_USERNAME=$(askFor 'display dialog "Wie lautet die E-Mail des Benutzers, der zum Verbinden verwendet werden soll?" default answer "vorname.nachname@bib.de"' ); if [[ $? != 0 ]]; then exit 2 ; fi
|
||||
NEW_VPN_HOST=$(askFor 'display dialog "Wie lautet der Servername?" default answer "vpn.bib.de"'); if [[ $? != 0 ]]; then exit 2 ; fi
|
||||
if [[ -z $NEW_VPN_NAME ]] ; then echo -n "Wie lautet der Name der neuen Verbindung? " ; read NEW_VPN_NAME ; fi
|
||||
if [[ -z $NEW_VPN_HOST ]] ; then echo -n "Wie lautet der VPN-Server? "; read NEW_VPN_HOST ; fi
|
||||
if [[ -z $NEW_VPN_USERNAME ]] ; then echo -n "Wie lautet die E-Mail des Benutzers? " ; read NEW_VPN_USERNAME ; fi
|
||||
|
||||
NEW_VPN_PUBKEY=$(gnutls-cli --print-cert $NEW_VPN_HOST |grep -e 'pin-.*:'|awk '{$1=$1;print}')
|
||||
NEW_VPN_PASSWORD=$(security find-generic-password -g -a $NEW_VPN_USERNAME 2>&1 >/dev/null)
|
||||
NEW_VPN_PASSWORD=$(security find-generic-password -g -a $NEW_VPN_USERNAME 2>&1 ) # >>$LOG) #>/dev/null)
|
||||
if [[ $NEW_VPN_PASSWORD =~ password ]] ; then
|
||||
echo "Es ist bereits ein Passwort im Schlüsselbund für $NEW_VPN_USERNAME hinterlegt."
|
||||
else
|
||||
echo -n "Es ist noch kein Passwort im Schlüsselbund hinterlegt Bitte einmal das Passwort angeben : " ;
|
||||
NEW_VPN_PASS = $(read )
|
||||
security add-generic-password -a $NEW_VPN_USERNAME -s openconnect -w $NEW_VPN_PASS
|
||||
echo -n "Es ist noch kein Passwort im Schlüsselbund hinterlegt. Bitte einmal das Passwort angeben : " ;
|
||||
NEW_VPN_PASSWORD=$(askFor 'display dialog "Es ist kein Passwort im Schlüsselbund vorhanden. Wie lautet das Passwort? " default answer "Mein Passwort..." with hidden answer')
|
||||
SAVE_PASSWORD=$(askFor 'display dialog "Soll das Passwort, dauerhaft im Schlüsselbund gespeichert werden? "')
|
||||
if [[ $SAVE_PASSWORD == "OK" ]] ; then
|
||||
security add-generic-password -a $NEW_VPN_USERNAME -s openconnect -w $NEW_VPN_PASSWORD
|
||||
fi
|
||||
fi
|
||||
echo "$NEW_VPN_NAME,$NEW_VPN_USERNAME,$NEW_VPN_HOST,$NEW_VPN_PUBKEY" #>> $ACCOUNTFILE
|
||||
echo "$NEW_VPN_NAME,$NEW_VPN_USERNAME,$NEW_VPN_HOST,$NEW_VPN_PUBKEY" >> $LOG >> $ACCOUNTFILE
|
||||
# Refreshen, damit das Profil direkt angezeigt wird.
|
||||
open swiftbar://refreshplugin?name=$(basename $0)
|
||||
osascript -e 'display notification "VPN Profil '$NEW_VPN_NAME' erfolgreich angelegt" with title "OpenVPN" subtitle "'$NEW_VPN_HOST' - '$NEW_VPN_USERNAME'" sound name "Brise"'
|
||||
;;
|
||||
openlog)
|
||||
open -a console $LOG
|
||||
;;
|
||||
openDIR)
|
||||
open ${WORKDIR}
|
||||
;;
|
||||
toggleColor)
|
||||
if [ $SHOW_COLOR == 'false' ];then SHOW_COLOR='true';else SHOW_COLOR='false' ; fi
|
||||
echo "Switche den Farbmodus ($SHOW_COLOR)" >> $LOG
|
||||
saveSettings
|
||||
;;
|
||||
toggleIcon)
|
||||
if [ $SHOW_ICON == 'false' ];then SHOW_ICON='true';else SHOW_ICON='false' ; fi
|
||||
echo "Switche den Iconmodus ($SHOW_ICON)" >> $LOG
|
||||
saveSettings
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -f $OC_PIDFILE ]; then
|
||||
if [ $SHOW_ICONS == 'ON' ]; then echo "| sfimage=firewall.fill | sfcolor=green" ; else echo "VPN ✔ |$FONT color=green" ; fi
|
||||
if [ $SHOW_ICON == 'true' ]; then echo ":firewall.fill:| sfcolor=$COLOR_CONNECTED sfsize=17" ; else echo "VPN ✔ | color=$COLOR_CONNECTED" ; fi
|
||||
echo '---'
|
||||
echo "Disconnect VPN | bash='$0' param1=disconnect terminal=false refresh=true"
|
||||
aUser=$(ps -ef | grep -e '--user\ ' | cut -d' ' -f 32)
|
||||
if [[ $aUser =~ .*@.* ]]; then echo "User: $aUser" ; fi
|
||||
echo "IP: $IP"
|
||||
echo "Verbunden seit: $(stat $OC_PIDFILE | cut -d'"' -f4)"
|
||||
pidTime=$(stat $OC_PIDFILE | cut -d'"' -f4)
|
||||
|
||||
|
||||
startZeit=$(date -j -f "%b %d %H:%M:%S %Y" "$pidTime" +%s)
|
||||
now=$(date +%s)
|
||||
seitZeit="$(( (now-startZeit) ))"
|
||||
echo "Verbunden seit: $pidTime ($seitZeit Sek ~ $(( seitZeit/60 )) Min) "
|
||||
showSettings
|
||||
exit
|
||||
else
|
||||
if [ $SHOW_ICONS == 'ON' ] ; then echo "| sfimage=firewall" ; else echo "VPN ❌ | $FONT color=Crimson" ; fi
|
||||
if [ $SHOW_ICON == 'true' ] ; then echo ":firewall:| sfcolor=$COLOR_UNCONNECTED sfsize=17" ; else echo "VPN X | color=$COLOR_UNCONNECTED" ; fi
|
||||
echo '---'
|
||||
# Alle User aus der accounts.csv auslesen und dann zur Auswahl anbieten.
|
||||
cat "$ACCOUNTFILE" | while IFS= read config;
|
||||
|
@@ -5,7 +5,7 @@
|
||||
# Grund : Schlanke Alternative zum fetten FortiClient VPN Only
|
||||
|
||||
# Variables
|
||||
PLUGINDIR="/Users/$USER/Library/Application\ Support/SwiftBar/plugins"
|
||||
PLUGINDIR='/Users/'$USER'/Library/SwiftBar/plugins'
|
||||
# Farben definieren
|
||||
noColor="\033[0m";
|
||||
Purple='\033[0;35m'
|
||||
@@ -24,7 +24,7 @@ brew update && brew install openconnect swiftbar
|
||||
echo -e "${Purple}Lade das Skript und stelle die Konfiguration für SwiftBar ein.${noColor}"
|
||||
|
||||
mkdir -p $PLUGINDIR && cd $PLUGINDIR
|
||||
defaults write /Users/$USER/Library/Preferences/com.ameba.SwiftBar.plist PluginDirectory $PLUGINDIR
|
||||
defaults write com.ameba.SwiftBar.plist PluginDirectory $PLUGINDIR
|
||||
wget https://git.bib.de/ITS/OpenConnect_macOS_Bar/raw/branch/main/bibVPN.sh
|
||||
chmod +x bibVPN.sh
|
||||
|
||||
|
BIN
menubar.png
Normal file
BIN
menubar.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 60 KiB |
Reference in New Issue
Block a user