fix: 更新脚本以支持远程数据库配置和修复文件路径
This commit is contained in:
@@ -10,7 +10,7 @@ echo " sudo systemctl start|stop|status|restart omc.service"
|
||||
echo ""
|
||||
|
||||
# Check if this is the first installation or upgrade
|
||||
if [ ! -f $RootDir/omc.conf ]; then
|
||||
if [ ! -f $RootDir/machine.ini ]; then
|
||||
# First installation, perform the related operations
|
||||
chmod +rx /usr/local/bin/omc
|
||||
cp $RootDir/default/omc.conf $RootDir/omc.conf
|
||||
|
||||
@@ -16,14 +16,14 @@ cp -nr "$BASE_DIR"/default/. "$BASE_DIR"
|
||||
|
||||
# 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
|
||||
bash /usr/local/etc/omc/script/setup.sh -i -r -m $M_PARAM -c $C_PARAM
|
||||
fi
|
||||
|
||||
# Start Nginx server
|
||||
nginx -g "daemon off;"
|
||||
|
||||
# Parse CLI flags to pass to the 'omc' call
|
||||
args=("--config" "${BASE_DIR}/omc.conf")
|
||||
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[@]}")
|
||||
|
||||
@@ -10,11 +10,14 @@ set -o pipefail
|
||||
. /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 -rf /usr/local/etc/omc/default/* "$BASE_DIR"
|
||||
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
|
||||
@@ -22,13 +25,13 @@ 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
|
||||
sed -i '/port: 6379 # Redis port/ {n; s/host: "127.0.0.1"/host: "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
|
||||
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
|
||||
|
||||
@@ -62,13 +62,11 @@ install(){
|
||||
docker load --input $(pwd)/tar/mariadb_10.6.21_{arch}.tar
|
||||
MYSQL_IMAGE="mariadb-{arch}:10.6.21"
|
||||
MYSQL_ROOT_PASSWORD="1000omc@kp!"
|
||||
# SQL_FILE_PATH="$(pwd)/sql/install/omc_db.sql"
|
||||
MYSQL_DATA=/usr/local/etc/$MYSQL_CONTAINER_NAME/data
|
||||
mkdir -p $MYSQL_DATA && chmod 777 $MYSQL_DATA
|
||||
echo "CREATE DATABASE IF NOT EXISTS omc_db;" >> $MYSQL_DATA/database.sql
|
||||
docker run --privileged=true --restart=always -e TZ="$OMC_TZ" \
|
||||
-e MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD \
|
||||
-v $SQL_FILE_PATH:/docker-entrypoint-initdb.d/database.sql \
|
||||
-e MARIADB_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD \
|
||||
-e MARIADB_DATABASE=omc_db \
|
||||
-v $MYSQL_DATA:/var/lib/mysql \
|
||||
--network $NETWORK \
|
||||
--name $MYSQL_CONTAINER_NAME \
|
||||
|
||||
Reference in New Issue
Block a user