1
0
Files
build.ems/pkg/docker/linux/usr/local/etc/omc/script/postunpack.sh
2025-05-20 18:47:08 +08:00

36 lines
1.6 KiB
Bash

#!/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
chmod -R g+rwX "$BASE_DIR" "$DATA_DIR"
# 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 -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 '/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