From 9aa514648866654306fa8eaf7139c6bf5827985f Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Tue, 4 Feb 2020 10:22:17 +0100 Subject: [PATCH] fix wait-for ldap port detection --- docker-compose.yml | 13 ++++++++++--- overlay/usr/local/bin/entrypoint.sh | 15 ++++++--------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 5c0abb1..5e54264 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,8 +10,12 @@ services: POSTGRES_PASSWORD: pass POSTGRES_USER: user + ldap: + container_name: bitwardenrs_ldap + image: osixia/openldap + bitwardenrs: - container_name: bitwardenrs + container_name: bitwardenrs_server image: xoxys/bitwardenrs:latest depends_on: - postgres @@ -24,13 +28,16 @@ services: BITWARDENRS_ADMIN_TOKEN: my_secure_token bitwardenrs_ldap: - container_name: bitwardenrs_ldap + container_name: bitwardenrs_ldap_sync image: xoxys/bitwardenrs_ldap:latest depends_on: - bitwardenrs + - ldap environment: - BITWARDENRS_LDAP_BITWARDEN_URL: http://bitwardenrs:8080 + BITWARDENRS_LDAP_BITWARDEN_URL: http://bitwardenrs_server:8080 BITWARDENRS_LDAP_BITWARDEN_ADMIN_TOKEN: my_secure_token + BITWARDENRS_LDAP_HOST: bitwardenrs_ldap + BITWARDENRS_LDAP_PORT: 389 volumes: data: diff --git a/overlay/usr/local/bin/entrypoint.sh b/overlay/usr/local/bin/entrypoint.sh index ac54343..c3cf36f 100755 --- a/overlay/usr/local/bin/entrypoint.sh +++ b/overlay/usr/local/bin/entrypoint.sh @@ -6,7 +6,7 @@ set -eo pipefail if [ -z "$BITWARDENRS_LDAP_BITWARDEN_URL" ] || [ -z "$BITWARDENRS_LDAP_HOST" ] then - printf "Error: Bitwarden and/or LDAP server not configured. Exiting ..." + printf "Error: Bitwarden and/or LDAP server not configured. Exiting ...\n" exit 1 fi @@ -16,9 +16,9 @@ then 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" ] + if [ -n "$WAITFOR_DB_PORT" ] then - [ "$WAITFOR_DB_SCHEME" = "http" ] && WAITFOR_DB_PORT=80 || WAITFOR_DB_PORT=443 + [ "$WAITFOR_DB_SCHEME" = "https" ] && WAITFOR_DB_PORT=433 || WAITFOR_DB_PORT=80 fi printf "Wait for bitwarden server on '%s:%s'...\n" "${WAITFOR_DB_HOST}" "${WAITFOR_DB_PORT}" @@ -27,13 +27,10 @@ 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 ] + WAITFOR_LDAP_SSL=$(/usr/local/bin/gomplate -i '{{ getenv "BITWARDENRS_LDAP_SSL" "true" | conv.Bool }}') + if [ -n "$WAITFOR_LDAP_PORT" ] then - WAITFOR_LDAP_PORT=636 - else - WAITFOR_LDAP_PORT=389 + [ "$WAITFOR_LDAP_SSL" = true ] && WAITFOR_LDAP_PORT=636 || WAITFOR_LDAP_PORT=389 fi printf "Wait for ldap server on '%s:%s'...\n" "${BITWARDENRS_LDAP_HOST}" "${WAITFOR_LDAP_PORT}"