1
0
Files
build.ems/pkg/docker/linux/usr/local/etc/omc/script/postunpack.sh
2025-05-21 14:23:58 +08:00

39 lines
1.7 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"
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
# cp $BASE_DIR/default/sshsvc.yaml $BASE_DIR/sshsvc.yaml
# 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 's/host: "127.0.0.1"$/host: "omc_mariadb"/' "$BASE_DIR"/omc.yaml
sed -i 's/port: 33066/port: 3306/' "$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_/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/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