1
0
Files
build.ems/pkg/docker/linux/usr/local/etc/omc/script/entrypoint.sh

35 lines
1009 B
Bash

#!/usr/bin/env bash
# shellcheck disable=SC1091
set -o errexit
set -o nounset
set -o pipefail
# set -o xtrace # Uncomment this line for debugging purposes
# Load OMC environment variables
. /usr/local/etc/omc/script/omc-env.sh
# We add the copy from default config in the entrypoint to not break users
# case someone mounts a configuration file in /usr/local/etc/omc/default)
cp -n $BASE_DIR/default/omc.conf $BASE_DIR/omc.conf
cp -n $BASE_DIR/default/omc.yaml $BASE_DIR/omc.yaml
# Initialize OMC DB
if [ ! -f /usr/local/etc/omc/machine.ini ]; then
bash /usr/local/etc/omc/script/setup.sh -i -r -m $M_PARAM -c $C_PARAM
fi
# Start Nginx server | -s stop
nginx
# Parse CLI flags to pass to the 'omc' call
args=("--config" "${BASE_DIR}/omc.yaml")
# Add flags specified via the 'CMD_EXTRA_FLAGS' environment variable
read -r -a extra_flags <<< "$CMD_EXTRA_FLAGS"
[[ "${#extra_flags[@]}" -gt 0 ]] && args+=("${extra_flags[@]}")
# Add flags passed to this script
args+=("$@")
# Run omc
omc "${args[@]}"