This repository has been archived on 2024-02-03. You can view files and clone it, but cannot push or open issues or pull requests.
vaultwarden-ldap/overlay/usr/local/bin/entrypoint

44 lines
1.5 KiB
Plaintext
Raw Normal View History

2020-01-18 23:19:48 +00:00
#!/usr/bin/env sh
# shellcheck disable=SC3040
2020-02-04 08:47:39 +00:00
set -eo pipefail
# shellcheck disable=SC1091
. /usr/local/lib/log.sh
2020-12-31 12:22:05 +00:00
/usr/local/bin/gomplate -o /app/config.toml -f /etc/templates/config.toml.tmpl
2020-01-18 23:19:48 +00:00
if [ -z "$VAULTWARDEN_LDAP_VAULTWARDEN_URL" ] || [ -z "$VAULTWARDEN_LDAP_HOST" ]; then
log_error "Error: Vaultwarden and/or LDAP server not configured, exiting"
2020-02-04 08:47:39 +00:00
exit 1
fi
if [ -n "$VAULTWARDEN_LDAP_VAULTWARDEN_URL" ]; then
2023-09-06 21:31:39 +00:00
WAITFOR_BW_SCHEME=$(/usr/local/bin/url-parser --url "$VAULTWARDEN_LDAP_VAULTWARDEN_URL" scheme)
WAITFOR_BW_HOST=$(/usr/local/bin/url-parser --url "$VAULTWARDEN_LDAP_VAULTWARDEN_URL" host)
WAITFOR_BW_PORT=$(/usr/local/bin/url-parser --url "$VAULTWARDEN_LDAP_VAULTWARDEN_URL" port)
2020-02-04 08:47:39 +00:00
if [ -z "$WAITFOR_BW_PORT" ]; then
2020-02-04 09:36:27 +00:00
[ "$WAITFOR_BW_SCHEME" = "https" ] && WAITFOR_BW_PORT=433 || WAITFOR_BW_PORT=80
2020-02-04 08:47:39 +00:00
fi
log_info "Wait for Vaultwarden server on '${WAITFOR_BW_HOST}:${WAITFOR_BW_PORT}'"
2020-02-04 09:36:27 +00:00
/usr/local/bin/wait-for "${WAITFOR_BW_HOST}":"${WAITFOR_BW_PORT}"
2020-02-04 08:47:39 +00:00
fi
if [ -n "$VAULTWARDEN_LDAP_HOST" ]; then
WAITFOR_LDAP_SSL=$(/usr/local/bin/gomplate -i '{{ getenv "VAULTWARDEN_LDAP_SSL" "true" | conv.ToBool }}')
2020-02-04 09:36:27 +00:00
if [ -z "$VAULTWARDEN_LDAP_PORT" ]; then
[ "$WAITFOR_LDAP_SSL" = true ] && VAULTWARDEN_LDAP_PORT=636 || VAULTWARDEN_LDAP_PORT=389
2020-02-04 08:47:39 +00:00
fi
log_info "Wait for LDAP server on '${VAULTWARDEN_LDAP_HOST}:${VAULTWARDEN_LDAP_PORT}'"
/usr/local/bin/wait-for "${VAULTWARDEN_LDAP_HOST}":"${VAULTWARDEN_LDAP_PORT}"
# TODO: add delay to minimize connection errors
sleep 10
2020-02-04 08:47:39 +00:00
fi
exec env CONFIG_PATH=/app/config.toml /app/vaultwarden_ldap