docs: clarify main vs v1.0.0-user deploy paths and fix deploy.sh git sync

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-30 20:43:56 +08:00
parent ec1c9873b7
commit b6a4f98b86
3 changed files with 145 additions and 54 deletions
+37 -14
View File
@@ -13,7 +13,8 @@
set -euo pipefail
APP_DIR="/opt/qihuo"
REPO_URL="https://git.bz121.com/dekun/qihuo.git"
REPO_URL="${QIHUO_REPO_URL:-https://gitee.com/dekun/qihuo.git}"
USER_EDITION_TAG="${QIHUO_USER_TAG:-v1.0.0-user}"
SERVICE_NAME="qihuo"
# SimNow 前置候选(按优先级;部署时自动 nc 探测)
@@ -45,18 +46,6 @@ ensure_locale_gen() {
fi
}
ensure_env_key() {
local file="$1" key="$2" val="$3"
if [ ! -f "$file" ]; then
return
fi
if grep -q "^${key}=" "$file"; then
return
fi
echo "${key}=${val}" >>"$file"
echo " .env 补全: ${key}=${val}"
}
pick_simnow_front() {
local host td_port md_port
for entry in "${SIMNOW_FRONTS[@]}"; do
@@ -89,6 +78,33 @@ update_simnow_front_in_env() {
fi
}
ensure_env_key() {
local file="$1" key="$2" val="$3"
if [ ! -f "$file" ]; then
return
fi
if grep -q "^${key}=" "$file"; then
return
fi
echo "${key}=${val}" >>"$file"
echo " .env 补全: ${key}=${val}"
}
is_user_edition_tree() {
[ -f "$APP_DIR/edition.py" ] && grep -q 'USER_EDITION = True' "$APP_DIR/edition.py" 2>/dev/null
}
sync_git_repo() {
if is_user_edition_tree; then
echo "==> 个人用户版:同步 tag ${USER_EDITION_TAG}(不拉 main"
git fetch origin --tags
git checkout -f "${USER_EDITION_TAG}"
return
fi
echo "==> 完整版:更新 main"
git pull origin main || git pull origin master || true
}
echo "==> 检查系统依赖..."
export DEBIAN_FRONTEND=noninteractive
apt-get update -qq
@@ -141,7 +157,7 @@ mkdir -p "$(dirname "$APP_DIR")"
if [ -d "$APP_DIR/.git" ]; then
echo "==> 更新已有仓库..."
cd "$APP_DIR"
git pull origin main || git pull origin master || true
sync_git_repo
else
if [ -d "$APP_DIR" ] && [ "$(ls -A "$APP_DIR" 2>/dev/null)" ]; then
echo "目录 ${APP_DIR} 已存在且非 git 仓库,请手动处理后重试"
@@ -149,6 +165,13 @@ else
fi
git clone "$REPO_URL" "$APP_DIR"
cd "$APP_DIR"
if [ "${QIHUO_USER_EDITION:-}" = "1" ]; then
echo "==> 首次部署个人用户版:checkout ${USER_EDITION_TAG}"
git fetch origin --tags
git checkout -f "${USER_EDITION_TAG}"
else
git checkout main 2>/dev/null || git checkout master 2>/dev/null || true
fi
fi
echo "==> Python 虚拟环境与依赖..."