44 lines
2.1 KiB
Bash
44 lines
2.1 KiB
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
|
|
|
|
chmod -R g+rwX "$BASE_DIR" "$DATA_DIR"
|
|
chmod +rx /usr/local/bin/omc
|
|
|
|
# We add the copy from default config in the entrypoint to not break users
|
|
# bypassing the setup.sh logic. If the file already exists do not overwrite (in
|
|
# case someone mounts a configuration file in /usr/local/etc/omc/default)
|
|
cp $BASE_DIR/default/omc.conf $BASE_DIR/omc.conf
|
|
cp $BASE_DIR/default/omc.yaml $BASE_DIR/omc.yaml
|
|
|
|
# OMC config
|
|
sed -i "s/addr: "0.0.0.0:33030" # route http port/addr: "0.0.0.0:$API_HTTP_PORT" # route http port/" "$BASE_DIR"/omc.yaml
|
|
sed -i "s/addr: "0.0.0.0:33443" # route https port/addr: "0.0.0.0:$API_HTTPS_PORT" # route https port/" "$BASE_DIR"/omc.yaml
|
|
sed -i 's/enabled: true # web server enabled/enabled: false # web server enabled/' "$BASE_DIR"/omc.yaml
|
|
sed -i 's/host: "127.0.0.1" # mysql host$/host: "omc_mariadb" # mysql host/' "$BASE_DIR"/omc.yaml
|
|
sed -i 's/port: 33066 # mysql port$/port: 3306 # mysql port/' "$BASE_DIR"/omc.yaml
|
|
sed -i 's/host: "127.0.0.1" # redis host$/host: "omc_keydb" # redis host/' "$BASE_DIR"/omc.yaml
|
|
|
|
# Nginx config
|
|
sed -i 's/#gzip on;/gzip on;/' /etc/nginx/nginx.conf
|
|
sed -i '/^include \/etc\/nginx\/conf.d/s/^/# /' /etc/nginx/nginx.conf
|
|
sed -i 's/include \/etc\/nginx\/http.d/include \/etc\/nginx\/conf.d/' /etc/nginx/nginx.conf
|
|
|
|
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
|
|
rm -rf /etc/nginx/conf.d && mkdir -p /etc/nginx/conf.d
|
|
|
|
cp -rf /usr/local/etc/omc/nginx/omc.conf /etc/nginx/conf.d
|
|
touch /usr/local/etc/omc/web/config.js && echo 'sessionStorage.clear()' | tee /usr/local/etc/omc/web/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
|