diff --git a/SSH-VPN-VNC/connect2jet b/SSH-VPN-VNC/connect2jet index 7a91d226ab143ac93ca04bc275933891974cd3c1..49b46904acfe19f16b20817207b2292c0d25ce3b 100755 --- a/SSH-VPN-VNC/connect2jet +++ b/SSH-VPN-VNC/connect2jet @@ -22,6 +22,7 @@ Example: EOF } + debug='' while getopts "g:p:r:hd" flag; do case "${flag}" in @@ -58,7 +59,8 @@ if [ -n "${port}" ]; then fi fi - +# Override Term information to make sure we use the ones on the servers +# export TERM=xterm-256color # Check if names are in .ssh/config remote_status=false gateway_status=false diff --git a/SSH-VPN-VNC/connect2vpn b/SSH-VPN-VNC/connect2vpn index 18255754f34d58678c4b4f97cb8f9d978525f910..9ce7a78f4fb40d709d03a43027b81a691ac2b8cf 100755 --- a/SSH-VPN-VNC/connect2vpn +++ b/SSH-VPN-VNC/connect2vpn @@ -8,15 +8,34 @@ # Connect to VPN from the University of Vienna # Watch connection -if [ ! -n ${VPN_USER} ]; then - echo "set VPN_USER to your u:account username" - exit 1 +vpninfos() { + infos=$(f5fpc --info) + status=$(echo "${infos}" | grep '/Common/Remote-Access' | head -n1 | cut -d' ' -f3) + cat <<EOF +[VPN] ${status} +[VPN] Connection Information. Use Ctrl+c to end. +=============================================================================== +${infos} +EOF +} + +if [ $# -eq 0 ]; then + if [ "${VPN_USER}" != "" ]; then + echo "[VPN] using '$VPN_USER'" + else + read -p "[VPN] u:account username: " VPN_USER + fi +else + VPN_USER=$1 + echo "[VPN] Using ${VPN_USER} as username" fi f5fpc -v 2> /dev/null 1>/dev/null if [ $? -ne 0 ]; then echo "[VPN] Install Big-IP Edge Client. f5fpc missing" exit 1 +else + echo "[VPN] $(f5fpc -v | head -n1)" fi read -p "[VPN] Full (1) or split (None) tunnel? (1/None): " REPLY @@ -27,31 +46,25 @@ else echo "[VPN] Connecting full-tunnel ..." cmd="f5fpc -s -t vpn.univie.ac.at:8443 -u ${VPN_USER}" fi -# Todo: Does not work? f5fpc is too slow -# Can happen that there is no return -# as of bad shutdown or so -# echo "[VPN] Checking for existing connections..." -# output=$(netstat | grep vpn.univie.ac.at | wc -l) -# if [ $output - 2 ]; then -# echo "[VPN] Found a running instance:" -# f5fpc --info -# read -p "[VPN] shutdown (1) or keep (none) ? " REPLY -# if [ "$REPLY" == "1" ]; then -# f5fpc -o -# echo "[VPN] disconnected" -# else -# exit -# fi -# fi echo "[VPN] Starting Monitor..." # Show status +export -f vpninfos +init=true while true; do f5fpc --info | grep "established" > /dev/null if [ $? -ne 0 ]; then + if ! $init; then + echo "[VPN] Restarting ..." + f5fpc -o + fi + echo "[VPN] Starting connection ..." eval $cmd + if $init; then + init=false + fi fi - watch -n 2 'f5fpc --info' + watch -n 2 vpninfos read -p "[VPN] Reconnect (1) or shutdown (None): " REPLY if [ "$REPLY" == "" ]; then break