openconnect-proxy/build/entrypoint.sh

27 lines
918 B
Bash
Raw Normal View History

2018-11-29 12:07:38 +00:00
#!/bin/sh
2019-10-16 06:16:25 +00:00
sed "s/^Port .*$/Port 8888/" -i /etc/tinyproxy.conf
/usr/bin/tinyproxy -c /etc/tinyproxy.conf
2018-11-29 12:07:38 +00:00
2019-10-16 06:16:25 +00:00
/usr/local/bin/microsocks -i 0.0.0.0 -p 8889 &
run () {
# Start openconnect
if [[ -z "${OPENCONNECT_PASSWORD}" ]]; then
# Ask for password
openconnect -u $OPENCONNECT_USER $OPENCONNECT_OPTIONS $OPENCONNECT_URL
elif [[ ! -z "${OPENCONNECT_PASSWORD}" ]] && [[ ! -z "${OPENCONNECT_MFA_CODE}" ]]; then
# Multi factor authentication (MFA)
(echo $OPENCONNECT_PASSWORD; echo $OPENCONNECT_MFA_CODE) | openconnect -u $OPENCONNECT_USER $OPENCONNECT_OPTIONS --passwd-on-stdin $OPENCONNECT_URL
elif [[ ! -z "${OPENCONNECT_PASSWORD}" ]]; then
# Standard authentication
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