fix: 更新Docker构建脚本
This commit is contained in:
@@ -10,21 +10,25 @@ set -o pipefail
|
||||
# Load OMC environment variables
|
||||
. /usr/local/etc/omc/script/omc-env.sh
|
||||
|
||||
# Initialize OMC DB
|
||||
if [ ! -f /usr/local/etc/omc/omc.conf ]; then
|
||||
bash /usr/local/etc/omc/script/setup.sh -i -m $M_PARAM -c $C_PARAM
|
||||
fi
|
||||
|
||||
# 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 -nr "$BASE_DIR"/default/. "$BASE_DIR"
|
||||
|
||||
if [[ "$*" = *"/usr/local/etc/omc/script/run.sh"* || "$*" = *"run.sh"* ]]; then
|
||||
# Ensure OMC is initialized
|
||||
omcd version
|
||||
# Start Nginx server
|
||||
nginx -g "daemon off;"
|
||||
# Initialize OMC DB
|
||||
if [ ! -f /usr/local/etc/omc/machine.ini ]; then
|
||||
bash /usr/local/etc/omc/script/setup.sh -i -m $M_PARAM -c $C_PARAM
|
||||
fi
|
||||
|
||||
echo ""
|
||||
exec "$@"
|
||||
# Start Nginx server
|
||||
nginx -g "daemon off;"
|
||||
|
||||
# Parse CLI flags to pass to the 'omc' call
|
||||
args=("--config" "${BASE_DIR}/omc.conf")
|
||||
# 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+=("$@")
|
||||
|
||||
omc --version
|
||||
exec omc "${args[@]}"
|
||||
|
||||
@@ -3,7 +3,7 @@ export BASE_DIR="/usr/local/etc/omc"
|
||||
export DATA_DIR="/usr/local/omc"
|
||||
|
||||
# OMC settings
|
||||
export M_PARAM="${M_PARAM:std}"
|
||||
export M_PARAM="${M_PARAM:-std}"
|
||||
export C_PARAM="${C_PARAM:-omc}"
|
||||
|
||||
# OMC Config settings
|
||||
|
||||
@@ -17,16 +17,19 @@ chmod -R g+rwX "$BASE_DIR" "$DATA_DIR"
|
||||
cp -rf /usr/local/etc/omc/default/* "$BASE_DIR"
|
||||
|
||||
# OMC config
|
||||
sed -i 's/port: 33030/port: $API_HTTP_PORT/' "$BASE_DIR"/omc.yaml
|
||||
sed -i 's/port: 33443/port: $API_HTTPS_PORT/' "$BASE_DIR"/omc.yaml
|
||||
sed -i "s/port: 33030/port: $API_HTTP_PORT/" "$BASE_DIR"/omc.yaml
|
||||
sed -i "s/port: 33443/port: $API_HTTPS_PORT/" "$BASE_DIR"/omc.yaml
|
||||
sed -i '/webServer:/,/-/s/^\( *enabled:\) true/\1 false/' "$BASE_DIR"/omc.yaml
|
||||
sed -i '/type: "mysql"/,/-/s/^\( *host:\) "127.0.0.1"/\1 "omc_mariadb"/' "$BASE_DIR"/omc.yaml
|
||||
sed -i 's/port: 33066/port: 3306/' "$BASE_DIR"/omc.yaml
|
||||
sed -i '/port: 6379 # Redis port/,/-/s/^\( *host:\) "127.0.0.1"/\1 "omc_keydb"/' "$BASE_DIR"/omc.yaml
|
||||
|
||||
# Nginx config
|
||||
sed -i 's/# gzip_/gzip_/' /etc/nginx/nginx.conf
|
||||
sed -i 's/include \/etc\/nginx\/sites-enabled/# include \/etc\/nginx\/sites-enabled/' /etc/nginx/nginx.conf
|
||||
cp -rf /usr/local/etc/omc/nginx/omc.conf /etc/nginx/conf.d
|
||||
touch /usr/local/etc/omc/web/dist/config.js && echo 'sessionStorage.clear()' | tee /web/dist/config.js
|
||||
sed -i 's/33030;/$API_HTTP_PORT;/' /etc/nginx/conf.d/omc.conf
|
||||
sed -i 's/33443;/$API_HTTPS_PORT;/' /etc/nginx/conf.d/omc.conf
|
||||
sed -i 's/80;/$WEB_HTTP_PORT;/' /etc/nginx/conf.d/omc.conf
|
||||
sed -i 's/443;/$WEB_HTTPS_PORT;/' /etc/nginx/conf.d/omc.conf
|
||||
sed -i "s/33030;/$API_HTTP_PORT;/" /etc/nginx/conf.d/omc.conf
|
||||
sed -i "s/33443;/$API_HTTPS_PORT;/" /etc/nginx/conf.d/omc.conf
|
||||
sed -i "s/80;/$WEB_HTTP_PORT;/" /etc/nginx/conf.d/omc.conf
|
||||
sed -i "s/443;/$WEB_HTTPS_PORT;/" /etc/nginx/conf.d/omc.conf
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
#!/bin/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
|
||||
|
||||
# Parse CLI flags to pass to the 'omc' call
|
||||
args=("--config" "${BASE_DIR}/omc.conf")
|
||||
# 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+=("$@")
|
||||
|
||||
exec omc "${args[@]}"
|
||||
Reference in New Issue
Block a user