forgeplus-deploy/setup.sh

80 lines
2.5 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
echo "开始检查安装文件..."
# 定义应用名称
app_name="gitlink"
# 定义要搜索的字符串
search_string="172.20.32.202"
# 定义要替换的新字符串
replace_string="172.20.32.135"
echo "检查代码目录路径是否存在..."
# 检查代码目录路径是否存在
if [ ! -d "02-forgeplus/forgeplus" ]; then
echo "代码目录路径不存在02-forgeplus/forgeplus"
# exit 1
echo "正在克隆代码到02-forgeplus/forgeplus"
git clone -b dev_local_v1 https://gitlink.org.cn/Trustie/forgeplus.git 02-forgeplus/forgeplus
sleep 2
rm -rf 02-forgeplus/forgeplus/public/react/build
echo "正在克隆代码到02-forgeplus/forgeplus/public/react/build"
git clone -b dev_local_v1 https://gitlink.org.cn/gitlink/build.git 02-forgeplus/forgeplus/public/react/build
fi
echo "检查代码库运行文件是否存在..."
# 检查代码库运行文件是否存在
if [ ! -f "01-gitea/gitea_hat" ]; then
echo "检查代码库运行文件不存在01-gitea/gitea_hat"
exit 1
fi
echo "检查GEM文件是否存在..."
# 检查GEM文件是否存在
if [ ! -d "02-forgeplus/bundle" ]; then
echo "GEM文件目录不存在02-forgeplus/bundle"
exit 1
fi
echo "初始化运行/data目录,并拷贝文件..."
mkdir -p /data/
mkdir -p /data/$app_name/
# 检查安装目录是否存在
if [ ! -d "/data/$app_name/packages/" ]; then
mkdir -p /data/$app_name/packages
cp -rf ./* /data/$app_name/packages/
mkdir -p /data/gitlink/packages/02-forgeplus/forgeplus/tmp/pids/
fi
echo "初始化运行配置文件..."
cp -rf .env /data/$app_name/packages/
cp -rf docker-compose.yml /data/$app_name/packages/
cp -rf 01-gitea/gitea /data/$app_name/packages/01-gitea/
cp -rf 02-forgeplus/config /data/$app_name/packages/02-forgeplus/
# 搜索并替换文件夹中所有文件的ip配置为新的部署ip配置
cd /data/$app_name/packages/
echo "开始搜索并替换文件夹中的ip配置$search_string为新的部署ip配置$replace_string..."
find "/data/$app_name/packages/" -type f -exec sed -i "s/$search_string/$replace_string/g" {} +
cp -rf 02-forgeplus/config/* 02-forgeplus/forgeplus/config/
cp -rf 01-gitea/gitea /data/
echo "搜索并替换完成"
chmod +x 01-gitea/gitea_hat
chmod +x -R 02-forgeplus/bundle
chmod +x -R 02-forgeplus/forgeplus/bin
echo "启动服务..."
# 启动服务
docker-compose -f docker-compose.yml up -d
sleep 3
docker exec -it forgeplus bin/rails db:migrate
echo "启动开源项目服务完成。"