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.sh

44 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env sh
set -eo pipefail
/usr/local/bin/gomplate -V -o /app/config.toml -f /etc/templates/config.toml.tmpl
if [ -z "$BITWARDENRS_LDAP_BITWARDEN_URL" ] || [ -z "$BITWARDENRS_LDAP_HOST" ]
then
printf "Error: Bitwarden and/or LDAP server not configured. Exiting ..."
exit 1
fi
if [ -n "$BITWARDENRS_LDAP_BITWARDEN_URL" ]
then
WAITFOR_DB_SCHEME=$(/usr/local/bin/url-parser scheme --url "$BITWARDENRS_LDAP_BITWARDEN_URL")
WAITFOR_DB_HOST=$(/usr/local/bin/url-parser host --url "$BITWARDENRS_LDAP_BITWARDEN_URL")
WAITFOR_DB_PORT=$(/usr/local/bin/url-parser port --url "$BITWARDENRS_LDAP_BITWARDEN_URL")
if [ -n "$WAITFOR_PORT" ]
then
[ "$WAITFOR_DB_SCHEME" = "http" ] && WAITFOR_DB_PORT=80 || WAITFOR_DB_PORT=443
fi
printf "Wait for bitwarden server on '%s:%s'...\n" "${WAITFOR_DB_HOST}" "${WAITFOR_DB_PORT}"
/usr/local/bin/wait-for "${WAITFOR_DB_HOST}":"${WAITFOR_DB_PORT}"
fi
if [ -n "$BITWARDENRS_LDAP_HOST" ]
then
WAITFOR_LDAP_PORT=$(/usr/local/bin/url-parser port --url "$BITWARDENRS_LDAP_BITWARDEN_URL")
if [ "$(/usr/local/bin/gomplate -i '{{ getenv "BITWARDENRS_LDAP_SSL" "true" | conv.Bool }}')" = true ]
then
WAITFOR_LDAP_PORT=636
else
WAITFOR_LDAP_PORT=389
fi
printf "Wait for ldap server on '%s:%s'...\n" "${BITWARDENRS_LDAP_HOST}" "${WAITFOR_LDAP_PORT}"
/usr/local/bin/wait-for "${BITWARDENRS_LDAP_HOST}":"${WAITFOR_LDAP_PORT}"
fi
exec env CONFIG_PATH=/app/config.toml /app/bitwarden_rs_ldap