#!/usr/bin/env bash set -euo pipefail # 适合 README 中 curl | bash 的安装入口。 # 它只负责 clone/pull 仓库,然后调用仓库内 scripts/deploy-ubuntu.sh。 REPO="${REPO:-git@git.n.xiaomi.com:wuyang6/zk-data-agent.git}" BRANCH="${BRANCH:-main}" APP_DIR="${APP_DIR:-/opt/zk-data-agent}" FORCE=0 usage() { cat <&2 usage >&2 exit 1 ;; esac done command -v git >/dev/null 2>&1 || { echo "Missing git. Please install git first." >&2 exit 1 } if [[ -d "${APP_DIR}/.git" ]]; then cd "${APP_DIR}" git fetch origin git checkout "${BRANCH}" if [[ "${FORCE}" == "1" ]]; then git reset --hard "origin/${BRANCH}" else git pull --ff-only origin "${BRANCH}" fi else git clone --branch "${BRANCH}" "${REPO}" "${APP_DIR}" cd "${APP_DIR}" fi bash scripts/deploy-ubuntu.sh "${BRANCH}" --skip-git