Run openconnect calls in an endless loop with 60s sleep on failure

This commit is contained in:
Wolfgang Klinger 2019-10-17 17:45:23 +02:00
parent d7bba950af
commit 46e2544936

View File

@ -5,14 +5,22 @@ sed "s/^Port .*$/Port 8888/" -i /etc/tinyproxy.conf
/usr/local/bin/microsocks -i 0.0.0.0 -p 8889 & /usr/local/bin/microsocks -i 0.0.0.0 -p 8889 &
# Start openconnect run () {
if [[ -z "${OPENCONNECT_PASSWORD}" ]]; then # Start openconnect
# Ask for password if [[ -z "${OPENCONNECT_PASSWORD}" ]]; then
openconnect -u $OPENCONNECT_USER $OPENCONNECT_OPTIONS $OPENCONNECT_URL # Ask for password
elif [[ ! -z "${OPENCONNECT_PASSWORD}" ]] && [[ ! -z "${OPENCONNECT_MFA_CODE}" ]]; then openconnect -u $OPENCONNECT_USER $OPENCONNECT_OPTIONS $OPENCONNECT_URL
# Multi factor authentication (MFA) elif [[ ! -z "${OPENCONNECT_PASSWORD}" ]] && [[ ! -z "${OPENCONNECT_MFA_CODE}" ]]; then
(echo $OPENCONNECT_PASSWORD; echo $OPENCONNECT_MFA_CODE) | openconnect -u $OPENCONNECT_USER $OPENCONNECT_OPTIONS --passwd-on-stdin $OPENCONNECT_URL # Multi factor authentication (MFA)
elif [[ ! -z "${OPENCONNECT_PASSWORD}" ]]; then (echo $OPENCONNECT_PASSWORD; echo $OPENCONNECT_MFA_CODE) | openconnect -u $OPENCONNECT_USER $OPENCONNECT_OPTIONS --passwd-on-stdin $OPENCONNECT_URL
# Standard authentication elif [[ ! -z "${OPENCONNECT_PASSWORD}" ]]; then
echo $OPENCONNECT_PASSWORD | openconnect -u $OPENCONNECT_USER $OPENCONNECT_OPTIONS --passwd-on-stdin $OPENCONNECT_URL # Standard authentication
fi echo $OPENCONNECT_PASSWORD | openconnect -u $OPENCONNECT_USER $OPENCONNECT_OPTIONS --passwd-on-stdin $OPENCONNECT_URL
fi
}
until (run); do
echo "openconnect exited. Restarting process in 60 seconds…" >&2
sleep 60
done