From b01ee492dbe09c2706ecc62e38acd713ec509549 Mon Sep 17 00:00:00 2001 From: Alexander Bocken Date: Sat, 3 Oct 2020 09:06:25 +0200 Subject: [PATCH] added status output to ethvpn --- .local/bin/tools/ethvpn | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/.local/bin/tools/ethvpn b/.local/bin/tools/ethvpn index 22a5f2a..2e41b33 100755 --- a/.local/bin/tools/ethvpn +++ b/.local/bin/tools/ethvpn @@ -1,13 +1,18 @@ #!/bin/sh user="abocken@student-net.ethz.ch" password_path="ETH/VPN" -if [ $(pgrep -c openconnect) -eq 0 ]; then - pass "$password_path" | sudo openconnect -g student-net -u "$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 +if [ "$1" = "status" ]; then + ping -c 2 -q webprint.ethz.ch > /dev/null && printf '🔬' + printf '\n' else - if ping -c 1 -W 2 -q webprint.ethz.ch ;then - sudo pkill openconnect && notify-send "ETH VPN" "ETH VPN disconnected" + if [ $(pgrep -c openconnect) -eq 0 ]; then + pass "$password_path" | sudo openconnect -g student-net -u "$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 + else + if ping -c 1 -W 2 -q webprint.ethz.ch ;then + sudo pkill openconnect && notify-send "ETH VPN" "ETH VPN disconnected" + fi fi fi