dotfiles/.local/bin/dmenuvpn
Alexander Bocken 6907760e58
various changes
modified:   .config/coc/history.json
	modified:   .config/gtk-2.0/gtkfilechooser.ini
	modified:   .config/newsboat/config
	modified:   .config/nvim/init.vim
	modified:   .config/qutebrowser/autoconfig.yml
	modified:   .config/qutebrowser/qsettings/QtProject.conf
	modified:   .config/zsh/.zshrc
	modified:   .local/bin/castscreen
	modified:   .local/bin/dmenuvpn
	modified:   .local/bin/statusbar/internet
	deleted:    .local/bin/tools/bright
	modified:   .local/bin/tools/ce
	modified:   .local/bin/tools/hover
	modified:   .local/bin/tools/ripper
	modified:   .local/bin/tools/startmpv
	modified:   .zprofile
2020-10-28 13:48:43 +01:00

33 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
PASS_DIR=Misc/SaferVPN
USER='alexander@bocken.org'
ETH_user="abocken@student-net.ethz.ch"
ETH_password_path="ETH/VPN"
if [ "$1" = "status" ]; then
if ping -c 1 -W 1 -q webprint.ethz.ch &> /dev/null
then
printf '🔬'
fi
pgrep openvpn > /dev/null && printf '🛡'
printf '\n'
else
choice="$(ls "${XDG_CONFIG_HOME}/openvpn/cfgs" | sed 's/\.ovpn//' | awk 'BEGIN {print "ETH"}; {print $0}' | dmenu -p 'connect with which vpn server?' -l 10)"
[ -z "$choice" ] && exit
if [ "$choice" = "ETH" ]; then
if [ $(pgrep -c openconnect) -eq 0 ]; then
pass "$ETH_password_path" | sudo openconnect -g student-net -u "$ETH_user" --passwd-on-stdin sslvpn.ethz.ch &
if ping -c 4 -W 6 -q webprint.ethz.ch ;then
notify-send "ETH VPN" "ETH VPN connected"
fi
elif ping -c 1 -W 2 -q webprint.ethz.ch ;then
sudo pkill openconnect && notify-send "ETH VPN" "ETH VPN disconnected"
fi
else
printf '%s\n%s\n' "$USER" "$(pass $PASS_DIR)" > /tmp/tmp_pass
[ -n "$choice" ] && st -t "openVPN" sudo openvpn --config "${XDG_CONFIG_HOME}/openvpn/cfgs/${choice}.ovpn" --auth-user-pass /tmp/tmp_pass & pkill -RTMIN+9 dwmblocks; sleep 2; rm -f /tmp/tmp_pass
fi
fi
pkill -RTMIN+9 dwmblocks