Run openconnect calls in an endless loop with 60s sleep on failure
This commit is contained in:
parent
d7bba950af
commit
46e2544936
@ -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
|
||||||
|
# Ask for password
|
||||||
openconnect -u $OPENCONNECT_USER $OPENCONNECT_OPTIONS $OPENCONNECT_URL
|
openconnect -u $OPENCONNECT_USER $OPENCONNECT_OPTIONS $OPENCONNECT_URL
|
||||||
elif [[ ! -z "${OPENCONNECT_PASSWORD}" ]] && [[ ! -z "${OPENCONNECT_MFA_CODE}" ]]; then
|
elif [[ ! -z "${OPENCONNECT_PASSWORD}" ]] && [[ ! -z "${OPENCONNECT_MFA_CODE}" ]]; then
|
||||||
# Multi factor authentication (MFA)
|
# Multi factor authentication (MFA)
|
||||||
(echo $OPENCONNECT_PASSWORD; echo $OPENCONNECT_MFA_CODE) | openconnect -u $OPENCONNECT_USER $OPENCONNECT_OPTIONS --passwd-on-stdin $OPENCONNECT_URL
|
(echo $OPENCONNECT_PASSWORD; echo $OPENCONNECT_MFA_CODE) | openconnect -u $OPENCONNECT_USER $OPENCONNECT_OPTIONS --passwd-on-stdin $OPENCONNECT_URL
|
||||||
elif [[ ! -z "${OPENCONNECT_PASSWORD}" ]]; then
|
elif [[ ! -z "${OPENCONNECT_PASSWORD}" ]]; then
|
||||||
# Standard authentication
|
# Standard authentication
|
||||||
echo $OPENCONNECT_PASSWORD | openconnect -u $OPENCONNECT_USER $OPENCONNECT_OPTIONS --passwd-on-stdin $OPENCONNECT_URL
|
echo $OPENCONNECT_PASSWORD | openconnect -u $OPENCONNECT_USER $OPENCONNECT_OPTIONS --passwd-on-stdin $OPENCONNECT_URL
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
until (run); do
|
||||||
|
echo "openconnect exited. Restarting process in 60 seconds…" >&2
|
||||||
|
sleep 60
|
||||||
|
done
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user