Skip to content
Snippets Groups Projects
Commit 5ae7c073 authored by Michael Blaschek's avatar Michael Blaschek :bicyclist:
Browse files

vpn update

parent cf46944f
Branches
Tags
No related merge requests found
......@@ -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
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment