openconnect-proxy/build/entrypoint.sh

24 lines
968 B
Bash
Raw Normal View History

2018-11-29 12:07:38 +00:00
#!/bin/sh
# Set proxy port
sed "s/^Port .*$/Port $HTTPS_PROXY_PORT/" -i /etc/tinyproxy.conf
2018-11-29 12:07:38 +00:00
# Start proxy
2019-10-15 06:11:23 +00:00
/usr/bin/tinyproxy -c /etc/tinyproxy.conf && echo "HTTP/S proxy listening on $HTTPS_PROXY_PORT"
2018-11-29 12:07:38 +00:00
# Start socks5 proxy
2019-10-15 06:11:23 +00:00
/usr/local/bin/microsocks -i 0.0.0.0 -p $SOCKS5_PROXY_PORT &
echo "socks5 proxy listening on $SOCKS5_PROXY_PORT"
2019-10-15 06:11:23 +00:00
# Start openconnect
if [[ -z "${OPENCONNECT_PASSWORD}" ]]; then
# Ask for password
openconnect -u $OPENCONNECT_USER $OPENCONNECT_OPTIONS $OPENCONNECT_URL
2019-10-15 06:11:23 +00:00
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
2019-10-15 06:11:23 +00:00
elif [[ ! -z "${OPENCONNECT_PASSWORD}" ]]; then
# Standard authentication
echo $OPENCONNECT_PASSWORD | openconnect -u $OPENCONNECT_USER $OPENCONNECT_OPTIONS --passwd-on-stdin $OPENCONNECT_URL
2019-10-15 06:11:23 +00:00
fi