Files
dekun 4743f3efdd fix: normalize deploy shell scripts to LF for Linux curl|bash
CRLF line endings broke manage.sh on Ubuntu (set -e and function syntax errors).
Add .gitattributes to keep *.sh on LF in git.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-02 08:41:15 +08:00

42 lines
1.1 KiB
Bash

#!/usr/bin/env bash
# deploy/lib/update.sh — git pull + compose build/up;保留 .env 与 volume
set -e
set -u
if [ -n "${BASH_VERSION:-}" ]; then
set -o pipefail
fi
LIB_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=common.sh
source "${LIB_DIR}/common.sh"
main_update() {
require_root
if ! REPO_ROOT="$(resolve_repo_root)"; then
die "未找到安装目录 ${INSTALL_ROOT},请先执行「1) 一键部署」"
fi
if ! repo_ready "${REPO_ROOT}"; then
die "安装不完整,请先执行「1) 一键部署」"
fi
step "更新 — Docker 环境检测"
ensure_docker
step "git pull"
if [[ -d "${REPO_ROOT}/.git" ]]; then
git -C "${REPO_ROOT}" fetch --all --prune
git -C "${REPO_ROOT}" checkout "${GIT_BRANCH}" 2>/dev/null || true
git -C "${REPO_ROOT}" pull --ff-only origin "${GIT_BRANCH}" \
|| git -C "${REPO_ROOT}" pull --ff-only
else
log "警告: 非 git 目录,跳过 pull"
fi
# 补全缺失 env key,不覆盖已有
ensure_dotenv "${REPO_ROOT}"
compose_up_build
verify_health || true
echo ""
log "更新完成(.env 与 data volume 已保留)"
}
main_update "$@"