diff --git a/bbmri/docker-compose.yml b/bbmri/docker-compose.yml index 4188714..b1a47b5 100644 --- a/bbmri/docker-compose.yml +++ b/bbmri/docker-compose.yml @@ -65,11 +65,10 @@ services: - "blaze-data:/app/data" labels: - "traefik.enable=true" - - "traefik.http.middlewares.ccp-auth.basicauth.users=${LDM_LOGIN}" - "traefik.http.routers.blaze_ccp.rule=PathPrefix(`/bbmri-localdatamanagement`)" - "traefik.http.middlewares.ccp_b_strip.stripprefix.prefixes=/bbmri-localdatamanagement" - "traefik.http.services.blaze_ccp.loadbalancer.server.port=8080" - - "traefik.http.routers.blaze_ccp.middlewares=ccp_b_strip,ccp-auth" + - "traefik.http.routers.blaze_ccp.middlewares=ccp_b_strip,auth" - "traefik.http.routers.blaze_ccp.tls=true" spot: diff --git a/bridgehead b/bridgehead index f18311a..3297c65 100755 --- a/bridgehead +++ b/bridgehead @@ -59,6 +59,7 @@ if [ -f "$PROJECT/docker-compose.override.yml" ]; then fi detectCompose +setLdmPassword case "$ACTION" in start) diff --git a/ccp/docker-compose.yml b/ccp/docker-compose.yml index dfc7d34..989cc84 100644 --- a/ccp/docker-compose.yml +++ b/ccp/docker-compose.yml @@ -65,11 +65,10 @@ services: - "blaze-data:/app/data" labels: - "traefik.enable=true" - - "traefik.http.middlewares.ccp-auth.basicauth.users=${LDM_LOGIN}" - "traefik.http.routers.blaze_ccp.rule=PathPrefix(`/ccp-localdatamanagement`)" - "traefik.http.middlewares.ccp_b_strip.stripprefix.prefixes=/ccp-localdatamanagement" - "traefik.http.services.blaze_ccp.loadbalancer.server.port=8080" - - "traefik.http.routers.blaze_ccp.middlewares=ccp_b_strip,ccp-auth" + - "traefik.http.routers.blaze_ccp.middlewares=ccp_b_strip,auth" - "traefik.http.routers.blaze_ccp.tls=true" spot: diff --git a/lib/functions.sh b/lib/functions.sh index b5a03a0..3dd47cb 100755 --- a/lib/functions.sh +++ b/lib/functions.sh @@ -11,6 +11,13 @@ detectCompose() { fi } +setLdmPassword() { + if [ -z "$LDM_PASSWORD" ]; then + log DEBUG "Transforming LDM_PASSWORD into LDM_LOGIN ..." + LDM_LOGIN=$(docker run --rm -it httpd:alpine htpasswd -nb $PROJECT $LDM_PASSWORD | tr -d '\n' | tr -d '\r') + fi +} + exitIfNotRoot() { if [ "$EUID" -ne 0 ]; then log "ERROR" "Please run as root" diff --git a/lib/setup-bridgehead-units.sh b/lib/setup-bridgehead-units.sh index 820d6f6..519f224 100755 --- a/lib/setup-bridgehead-units.sh +++ b/lib/setup-bridgehead-units.sh @@ -35,15 +35,12 @@ EOF # TODO: Determine wether this should be located in setup-bridgehead (triggered through bridgehead install) or in update bridgehead (triggered every hour) if [ -z "$LDM_LOGIN" ]; then - log "INFO" "Now generating a password for the local datamangement. Please safe the password for your ETL process!" + log "INFO" "Now generating a password for the local data management. Please save the password for your ETL process!" generated_passwd="$(cat /proc/sys/kernel/random/uuid | sed 's/[-]//g' | head -c 20)" log "INFO" "Your generated credentials are:\n user: $PROJECT\n password: $generated_passwd" parsed_passwd=$(docker run --rm -it httpd:latest htpasswd -nb $PROJECT $generated_passwd | tr -d '\n' | tr -d '\r') - printf "##Localdatamanagement basic auth\n#User: $PROJECT\n#Password: $generated_passwd\n" >> /etc/bridgehead/${PROJECT}.local.conf; - - log "INFO" "These credentials are now written to /etc/bridgehead/${PROJECT}.local.conf" - echo -n "LDM_LOGIN='${parsed_passwd}'" >> /etc/bridgehead/${PROJECT}.local.conf; + echo -e "## Local Data Management Basic Authentication\n# User: $PROJECT\nLDM_PASSWORD=$generated_passwd" >> /etc/bridgehead/${PROJECT}.local.conf; fi log "INFO" "Register system units for bridgehead and bridgehead-update"