#!/usr/bin/env bash set -euo pipefail # 从 git 拉取/更新仓库,然后调用仓库内 scripts/deploy-ubuntu.sh。 REPO="${REPO:-git@git.n.xiaomi.com:wuyang6/zk-data-agent.git}" BRANCH="${BRANCH:-main}" APP_DIR="${APP_DIR:-${HOME}/zk-data-agent}" FORCE=0 BOOTSTRAP_SYSTEM="${BOOTSTRAP_SYSTEM:-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 deploy_args=("${BRANCH}" "--skip-git") if [[ "${BOOTSTRAP_SYSTEM}" == "1" ]]; then deploy_args+=("--bootstrap-system") fi bash scripts/deploy-ubuntu.sh "${deploy_args[@]}"