fix wait-for ldap port detection
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Robert Kaussow 2020-02-04 10:22:17 +01:00
parent 49e880431c
commit 9aa5146488
2 changed files with 16 additions and 12 deletions

View File

@ -10,8 +10,12 @@ services:
POSTGRES_PASSWORD: pass POSTGRES_PASSWORD: pass
POSTGRES_USER: user POSTGRES_USER: user
ldap:
container_name: bitwardenrs_ldap
image: osixia/openldap
bitwardenrs: bitwardenrs:
container_name: bitwardenrs container_name: bitwardenrs_server
image: xoxys/bitwardenrs:latest image: xoxys/bitwardenrs:latest
depends_on: depends_on:
- postgres - postgres
@ -24,13 +28,16 @@ services:
BITWARDENRS_ADMIN_TOKEN: my_secure_token BITWARDENRS_ADMIN_TOKEN: my_secure_token
bitwardenrs_ldap: bitwardenrs_ldap:
container_name: bitwardenrs_ldap container_name: bitwardenrs_ldap_sync
image: xoxys/bitwardenrs_ldap:latest image: xoxys/bitwardenrs_ldap:latest
depends_on: depends_on:
- bitwardenrs - bitwardenrs
- ldap
environment: 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_BITWARDEN_ADMIN_TOKEN: my_secure_token
BITWARDENRS_LDAP_HOST: bitwardenrs_ldap
BITWARDENRS_LDAP_PORT: 389
volumes: volumes:
data: data:

View File

@ -6,7 +6,7 @@ set -eo pipefail
if [ -z "$BITWARDENRS_LDAP_BITWARDEN_URL" ] || [ -z "$BITWARDENRS_LDAP_HOST" ] if [ -z "$BITWARDENRS_LDAP_BITWARDEN_URL" ] || [ -z "$BITWARDENRS_LDAP_HOST" ]
then then
printf "Error: Bitwarden and/or LDAP server not configured. Exiting ..." printf "Error: Bitwarden and/or LDAP server not configured. Exiting ...\n"
exit 1 exit 1
fi fi
@ -16,9 +16,9 @@ then
WAITFOR_DB_HOST=$(/usr/local/bin/url-parser host --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") WAITFOR_DB_PORT=$(/usr/local/bin/url-parser port --url "$BITWARDENRS_LDAP_BITWARDEN_URL")
if [ -n "$WAITFOR_PORT" ] if [ -n "$WAITFOR_DB_PORT" ]
then 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 fi
printf "Wait for bitwarden server on '%s:%s'...\n" "${WAITFOR_DB_HOST}" "${WAITFOR_DB_PORT}" 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" ] if [ -n "$BITWARDENRS_LDAP_HOST" ]
then then
WAITFOR_LDAP_PORT=$(/usr/local/bin/url-parser port --url "$BITWARDENRS_LDAP_BITWARDEN_URL") WAITFOR_LDAP_SSL=$(/usr/local/bin/gomplate -i '{{ getenv "BITWARDENRS_LDAP_SSL" "true" | conv.Bool }}')
if [ -n "$WAITFOR_LDAP_PORT" ]
if [ "$(/usr/local/bin/gomplate -i '{{ getenv "BITWARDENRS_LDAP_SSL" "true" | conv.Bool }}')" = true ]
then then
WAITFOR_LDAP_PORT=636 [ "$WAITFOR_LDAP_SSL" = true ] && WAITFOR_LDAP_PORT=636 || WAITFOR_LDAP_PORT=389
else
WAITFOR_LDAP_PORT=389
fi fi
printf "Wait for ldap server on '%s:%s'...\n" "${BITWARDENRS_LDAP_HOST}" "${WAITFOR_LDAP_PORT}" printf "Wait for ldap server on '%s:%s'...\n" "${BITWARDENRS_LDAP_HOST}" "${WAITFOR_LDAP_PORT}"