Files
eth_hedge_sim/deploy/lib/install.sh
T
dekun da5eb4c18c Add Fleet control plane and split manage.sh deploy menu.
Strategy nodes gain fleet token APIs; control/ app for local ops; manage.sh offers strategy vs control one-click deploy.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-30 10:46:40 +08:00

70 lines
1.6 KiB
Bash
Executable File

#!/usr/bin/env bash
# deploy/lib/install.sh — 一键部署策略机
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"
run_pipeline() {
local root="$1"
REPO_ROOT="${root}"
step "构建并启动策略机 (pull_and_restart.sh)"
bash "${REPO_ROOT}/deploy/pull_and_restart.sh"
pm2_save_startup
verify_health || true
print_post_install_guide
}
install_fresh() {
require_root
step "一键部署策略机 — 环境检测与依赖"
ensure_system_deps
step "克隆仓库 → ${INSTALL_ROOT}"
if [[ -d "${INSTALL_ROOT}" ]]; then
die "目录已存在: ${INSTALL_ROOT},请先卸载或选修复"
fi
mkdir -p "$(dirname "${INSTALL_ROOT}")"
git clone -b "${GIT_BRANCH}" "${GIT_URL}" "${INSTALL_ROOT}"
run_pipeline "${INSTALL_ROOT}"
}
install_repair() {
require_root
step "修复部署 — 环境检测与依赖"
ensure_system_deps
if ! REPO_ROOT="$(resolve_repo_root)"; then
die "未找到安装目录 ${INSTALL_ROOT}"
fi
step "修复环境(保留 .env 与数据库)"
run_pipeline "${REPO_ROOT}"
}
handle_existing() {
echo ""
echo "检测到已部署: ${INSTALL_ROOT}"
echo " a) 取消"
echo " b) 修复/重装环境(保留 .env 与 SQLite)"
local choice=""
cm_read choice "请选择 [a/b]: "
case "${choice}" in
b|B) install_repair ;;
*) log "已取消" ;;
esac
}
main_install() {
require_root
if repo_ready "${INSTALL_ROOT}"; then
handle_existing
else
install_fresh
fi
}
main_install "$@"