diff --git a/nginx/config/entrypoint.sh b/nginx/config/entrypoint.sh index a6eeec9e..ca661412 100644 --- a/nginx/config/entrypoint.sh +++ b/nginx/config/entrypoint.sh @@ -1,5 +1,5 @@ -#!/bin/sh -# Wazuh App Copyright (C) 2019 Wazuh Inc. (License GPLv2) +#!/bin/bash +# Wazuh App Copyright (C) 2018 Wazuh Inc. (License GPLv2) set -e @@ -12,15 +12,27 @@ else echo "SSL certificates already present" fi -# Configuring default credentiales. +# Setting users credentials. if [ ! -f /etc/nginx/conf.d/kibana.htpasswd ]; then - echo "Setting Nginx credentials" - echo $NGINX_PWD|htpasswd -i -c /etc/nginx/conf.d/kibana.htpasswd $NGINX_NAME >/dev/null + echo "Setting users credentials" + if [ ! -z "$NGINX_CREDENTIALS" ]; then + IFS=';' read -r -a users <<< "$NGINX_CREDENTIALS" + for index in "${!users[@]}" + do + IFS=':' read -r -a credentials <<< "${users[index]}" + if [ $index -eq 0 ]; then + echo ${credentials[1]}|htpasswd -i -c /etc/nginx/conf.d/kibana.htpasswd ${credentials[0]} >/dev/null + else + echo ${credentials[1]}|htpasswd -i /etc/nginx/conf.d/kibana.htpasswd ${credentials[0]} >/dev/null + fi + done + else + echo $NGINX_PWD|htpasswd -i -c /etc/nginx/conf.d/kibana.htpasswd $NGINX_NAME >/dev/null + fi else echo "Kibana credentials already configured" fi - if [ "x${NGINX_PORT}" = "x" ]; then NGINX_PORT=443 fi