mirror of https://github.com/OpenVidu/openvidu.git
deployment: openvidu-server & openvidu-server-pro entrypoint improvements
- Create directory /run/secrets/coturn just when it is necessary to generate a new secret file for COTURN_SHARED_SECRET_KEY. (Docker daemon should generate it anyways while running - Use `tr -dc '[:alnum:]' </dev/urandom` instead of `tr -dc A-Za-z0-9 </dev/urandom` to generate alphanumeric COTURN_SHARED_SECRET_KEY - Define possible empty variables at the beginning of the entrypoint. - Fail script on any error with `set -o errexit -o errtrace -o pipefail -o nounset` - More meaningfull message while waiting Kibana servicepull/715/head
parent
d0aedc70cf
commit
34be4d8c13
|
@ -1,10 +1,26 @@
|
|||
#!/bin/bash
|
||||
set -o errexit -o errtrace -o pipefail -o nounset
|
||||
|
||||
# Set possible empty environment variables
|
||||
export COTURN_SHARED_SECRET_KEY="${COTURN_SHARED_SECRET_KEY:-}"
|
||||
export WAIT_KIBANA_URL="${WAIT_KIBANA_URL:-}"
|
||||
export OV_CE_DEBUG_LEVEL="${OV_CE_DEBUG_LEVEL:-}"
|
||||
export JAVA_OPTIONS=${JAVA_OPTIONS:-}
|
||||
export COTURN_IP="${COTURN_IP:-auto-ipv4}"
|
||||
|
||||
|
||||
# Generate Coturn shared secret key, if COTURN_SHARED_SECRET_KEY is not defined
|
||||
if [[ -z "${COTURN_SHARED_SECRET_KEY}" ]]; then
|
||||
# Check if random sahred key is generated and with value
|
||||
|
||||
# Check if random shared key is generated and with value
|
||||
if [[ ! -f /run/secrets/coturn/shared-secret-key ]]; then
|
||||
RANDOM_COTURN_SECRET="$(tr -dc A-Za-z0-9 </dev/urandom | head -c 35 ; echo '')"
|
||||
# Generate directory just in case
|
||||
mkdir -p /run/secrets/coturn
|
||||
|
||||
# Generate random coturn secret
|
||||
RANDOM_COTURN_SECRET="$(tr -dc '[:alnum:]' </dev/urandom | head -c 35)"
|
||||
|
||||
# Replace value and generate shared-secret-key file
|
||||
sed "s|{{COTURN_SHARED_SECRET_KEY}}|${RANDOM_COTURN_SECRET}|g" \
|
||||
/usr/local/coturn-shared-key.template > /run/secrets/coturn/shared-secret-key
|
||||
fi
|
||||
|
@ -15,16 +31,16 @@ if [[ -z "${COTURN_SHARED_SECRET_KEY}" ]]; then
|
|||
fi
|
||||
|
||||
# Wait for kibana
|
||||
if [ ! -z "${WAIT_KIBANA_URL}" ]; then
|
||||
if [ -n "${WAIT_KIBANA_URL}" ]; then
|
||||
printf "\n"
|
||||
printf "\n ======================================="
|
||||
printf "\n = WAIT KIBANA ="
|
||||
printf "\n Waiting for Kibana service."
|
||||
printf "\n ======================================="
|
||||
printf "\n"
|
||||
|
||||
until $(curl --insecure --output /dev/null --silent --head --fail --max-time 10 --connect-timeout 10 ${WAIT_KIBANA_URL})
|
||||
until "$(curl --insecure --output /dev/null --silent --head --fail --max-time 10 --connect-timeout 10 "${WAIT_KIBANA_URL}")"
|
||||
do
|
||||
printf "\n Waiting for kibana in '%s' URL..." "${WAIT_KIBANA_URL}"
|
||||
printf "\n Waiting for kibana in '%s' 'URL'. This may take some minutes, please be patient" "${WAIT_KIBANA_URL}"
|
||||
sleep 1
|
||||
done
|
||||
printf "\n ==== Kibana is Ready ===="
|
||||
|
@ -38,7 +54,6 @@ printf "\n ======================================="
|
|||
printf "\n"
|
||||
|
||||
# Get coturn public ip
|
||||
[[ -z "${COTURN_IP}" ]] && export COTURN_IP=auto-ipv4
|
||||
if [[ "${COTURN_IP}" == "auto-ipv4" ]]; then
|
||||
COTURN_IP=$(/usr/local/bin/discover_my_public_ip.sh)
|
||||
elif [[ "${COTURN_IP}" == "auto-ipv6" ]]; then
|
||||
|
@ -49,8 +64,10 @@ if [[ "${OV_CE_DEBUG_LEVEL}" == "DEBUG" ]]; then
|
|||
export LOGGING_LEVEL_IO_OPENVIDU_SERVER=DEBUG
|
||||
fi
|
||||
|
||||
if [ ! -z "${JAVA_OPTIONS}" ]; then
|
||||
if [ -n "${JAVA_OPTIONS}" ]; then
|
||||
printf "\n Using java options: %s" "${JAVA_OPTIONS}"
|
||||
fi
|
||||
|
||||
# Here we don't expand variables to be interpreted as separated arguments
|
||||
# shellcheck disable=SC2086
|
||||
java ${JAVA_OPTIONS:-} -jar openvidu-server.jar
|
||||
|
|
|
@ -1,4 +1,10 @@
|
|||
#!/bin/bash
|
||||
set -o errexit -o errtrace -o pipefail -o nounset
|
||||
|
||||
export COTURN_SHARED_SECRET_KEY="${COTURN_SHARED_SECRET_KEY:-}"
|
||||
export OV_CE_DEBUG_LEVEL="${OV_CE_DEBUG_LEVEL:-}"
|
||||
export JAVA_OPTIONS=${JAVA_OPTIONS:-}
|
||||
export COTURN_IP="${COTURN_IP:-auto-ipv4}"
|
||||
|
||||
printf "\n"
|
||||
printf "\n ======================================="
|
||||
|
@ -8,9 +14,16 @@ printf "\n"
|
|||
|
||||
# Generate Coturn shared secret key, if COTURN_SHARED_SECRET_KEY is not defined
|
||||
if [[ -z "${COTURN_SHARED_SECRET_KEY}" ]]; then
|
||||
# Check if random sahred key is generated and with value
|
||||
|
||||
# Check if random shared key is generated and with value
|
||||
if [[ ! -f /run/secrets/coturn/shared-secret-key ]]; then
|
||||
RANDOM_COTURN_SECRET="$(tr -dc A-Za-z0-9 </dev/urandom | head -c 35 ; echo '')"
|
||||
# Generate directory just in case
|
||||
mkdir -p /run/secrets/coturn
|
||||
|
||||
# Generate random coturn secret
|
||||
RANDOM_COTURN_SECRET="$(tr -dc '[:alnum:]' </dev/urandom | head -c 35)"
|
||||
|
||||
# Replace value and generate shared-secret-key file
|
||||
sed "s|{{COTURN_SHARED_SECRET_KEY}}|${RANDOM_COTURN_SECRET}|g" \
|
||||
/usr/local/coturn-shared-key.template > /run/secrets/coturn/shared-secret-key
|
||||
fi
|
||||
|
@ -21,7 +34,6 @@ if [[ -z "${COTURN_SHARED_SECRET_KEY}" ]]; then
|
|||
fi
|
||||
|
||||
# Get coturn public ip
|
||||
[[ -z "${COTURN_IP}" ]] && export COTURN_IP=auto-ipv4
|
||||
if [[ "${COTURN_IP}" == "auto-ipv4" ]]; then
|
||||
COTURN_IP=$(/usr/local/bin/discover_my_public_ip.sh)
|
||||
elif [[ "${COTURN_IP}" == "auto-ipv6" ]]; then
|
||||
|
@ -32,8 +44,10 @@ if [[ "${OV_CE_DEBUG_LEVEL}" == "DEBUG" ]]; then
|
|||
export LOGGING_LEVEL_IO_OPENVIDU_SERVER=DEBUG
|
||||
fi
|
||||
|
||||
if [ ! -z "${JAVA_OPTIONS}" ]; then
|
||||
if [ -n "${JAVA_OPTIONS}" ]; then
|
||||
printf "\n Using java options: %s" "${JAVA_OPTIONS}"
|
||||
fi
|
||||
|
||||
# Here we don't expand variables to be interpreted as separated arguments
|
||||
# shellcheck disable=SC2086
|
||||
java ${JAVA_OPTIONS:-} -jar openvidu-server.jar
|
||||
|
|
Loading…
Reference in New Issue