deployment: Add some missing changes from cb8d87aecc

pull/780/head
cruizba 2023-03-08 18:09:48 +01:00
parent cb8d87aecc
commit 7a8f7fb5d1
3 changed files with 78 additions and 13 deletions

View File

@ -206,13 +206,72 @@ is_external_url() {
fi fi
} }
is_elasticsearch_enabled() {
local ELASTICSEARCH_ENABLED
ELASTICSEARCH_ENABLED=$(grep -v '^#' .env | grep OPENVIDU_PRO_ELASTICSEARCH_ENABLED | cut -d '=' -f2)
# First check if empty
if [[ -z "$ELASTICSEARCH_ENABLED" ]]; then
# If empty, then elasticsearch is enabled
return 0
fi
# If not empty, then check if true
if [[ "$ELASTICSEARCH_ENABLED" == "true" ]]; then
return 0
else
return 1
fi
}
is_elasticsearch_secured() {
local ELASTICSEARCH_USER
local ELASTICSEARCH_PASSWORD
ELASTICSEARCH_USER=$(grep -v '^#' .env | grep ELASTICSEARCH_USER | cut -d '=' -f2)
ELASTICSEARCH_PASSWORD=$(grep -v '^#' .env | grep ELASTICSEARCH_PASSWORD | cut -d '=' -f2)
# First check if empty
if [[ -z "$ELASTICSEARCH_USER" ]] || [[ -z "$ELASTICSEARCH_PASSWORD" ]]; then
# If empty, then elasticsearch is not secured
printf "ERROR: The elasticsearch user or password is empty."
printf "\nVariables ELASTICSEARCH_USER and ELASTICSEARCH_PASSWORD in the .env file are mandatory"
return 1
fi
# Check that password is greater than 6 characters
if [[ ${#ELASTICSEARCH_PASSWORD} -lt 6 ]]; then
printf "ERROR: Variable ELASTICSEARCH_PASSWORD in the .env file must be greater than 6 characters"
return 1
fi
return 0
}
start_openvidu() { start_openvidu() {
local RUN_LOCAL_FILEBEAT
local RUN_LOCAL_METRICBEAT
COTURN_IN_MEDIA_NODES=$(grep -v '^#' .env | grep COTURN_IN_MEDIA_NODES | cut -d '=' -f2) COTURN_IN_MEDIA_NODES=$(grep -v '^#' .env | grep COTURN_IN_MEDIA_NODES | cut -d '=' -f2)
RUN_LOCAL_FILEBEAT=true
RUN_LOCAL_METRICBEAT=true
if [[ -z "${COTURN_IN_MEDIA_NODES}" ]]; then if [[ -z "${COTURN_IN_MEDIA_NODES}" ]]; then
COTURN_IN_MEDIA_NODES=false COTURN_IN_MEDIA_NODES=false
fi fi
if is_elasticsearch_enabled; then
# If elastic is enabled, check credentials
if ! is_elasticsearch_secured; then
exit 1
fi
else
RUN_LOCAL_FILEBEAT=false
RUN_LOCAL_METRICBEAT=false
fi
docker-compose up -d \ docker-compose up -d \
$(if [ "${COTURN_IN_MEDIA_NODES}" == "true" ]; then echo '--scale coturn=0'; fi) $(if [ "${COTURN_IN_MEDIA_NODES}" == "true" ]; then echo '--scale coturn=0'; fi) \
$(if [ "${RUN_LOCAL_FILEBEAT}" == "true" ]; then echo 'filebeat'; fi) \
$(if [ "${RUN_LOCAL_METRICBEAT}" == "true" ]; then echo 'metricbeat'; fi)
} }
usage() { usage() {

View File

@ -290,16 +290,13 @@ start_openvidu() {
fi fi
if is_elasticsearch_enabled; then if is_elasticsearch_enabled; then
RUN_LOCAL_ES=false
RUN_LOCAL_KIBANA=false # If elastic is enabled, check credentials
RUN_LOCAL_FILEBEAT=false
RUN_LOCAL_METRICBEAT=false
else
# If elastic is not enabled, check credentials, and check if external elasticsearch is configured
if ! is_elasticsearch_secured; then if ! is_elasticsearch_secured; then
exit 1 exit 1
fi fi
# Check if external elasticsearch is configured
if is_external_url "${CONFIGURED_ELASTICSEARCH_HOST}"; then if is_external_url "${CONFIGURED_ELASTICSEARCH_HOST}"; then
printf "Configured external elasticsearch: %s" "${CONFIGURED_ELASTICSEARCH_HOST}" printf "Configured external elasticsearch: %s" "${CONFIGURED_ELASTICSEARCH_HOST}"
printf "\n" printf "\n"
@ -310,6 +307,12 @@ start_openvidu() {
printf "\n" printf "\n"
RUN_LOCAL_KIBANA=false RUN_LOCAL_KIBANA=false
fi fi
else
RUN_LOCAL_ES=false
RUN_LOCAL_KIBANA=false
RUN_LOCAL_FILEBEAT=false
RUN_LOCAL_METRICBEAT=false
fi fi

View File

@ -266,16 +266,13 @@ start_openvidu() {
fi fi
if is_elasticsearch_enabled; then if is_elasticsearch_enabled; then
RUN_LOCAL_ES=false
RUN_LOCAL_KIBANA=false # If elastic is enabled, check credentials
RUN_LOCAL_FILEBEAT=false
RUN_LOCAL_METRICBEAT=false
else
# If elastic is not enabled, check credentials, and check if external elasticsearch is configured
if ! is_elasticsearch_secured; then if ! is_elasticsearch_secured; then
exit 1 exit 1
fi fi
# Check if external elasticsearch is configured
if is_external_url "${CONFIGURED_ELASTICSEARCH_HOST}"; then if is_external_url "${CONFIGURED_ELASTICSEARCH_HOST}"; then
printf "Configured external elasticsearch: %s" "${CONFIGURED_ELASTICSEARCH_HOST}" printf "Configured external elasticsearch: %s" "${CONFIGURED_ELASTICSEARCH_HOST}"
printf "\n" printf "\n"
@ -286,6 +283,12 @@ start_openvidu() {
printf "\n" printf "\n"
RUN_LOCAL_KIBANA=false RUN_LOCAL_KIBANA=false
fi fi
else
RUN_LOCAL_ES=false
RUN_LOCAL_KIBANA=false
RUN_LOCAL_FILEBEAT=false
RUN_LOCAL_METRICBEAT=false
fi fi