27 lines
682 B
Bash
27 lines
682 B
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
if [[ "${EUID}" -ne 0 ]]; then
|
|
echo "hecate-self-update.sh must run as root" >&2
|
|
exit 1
|
|
fi
|
|
|
|
REPO_URL="${HECATE_REPO_URL:-https://scm.bstein.dev/bstein/hecate.git}"
|
|
BRANCH="${HECATE_REPO_BRANCH:-main}"
|
|
REPO_DIR="${HECATE_REPO_DIR:-/opt/hecate}"
|
|
|
|
mkdir -p "$(dirname "${REPO_DIR}")"
|
|
if [[ ! -d "${REPO_DIR}/.git" ]]; then
|
|
echo "[self-update] cloning ${REPO_URL} into ${REPO_DIR}"
|
|
git clone "${REPO_URL}" "${REPO_DIR}"
|
|
fi
|
|
|
|
cd "${REPO_DIR}"
|
|
echo "[self-update] syncing ${BRANCH}"
|
|
git fetch origin --prune
|
|
git checkout "${BRANCH}"
|
|
git reset --hard "origin/${BRANCH}"
|
|
|
|
echo "[self-update] running installer"
|
|
"${REPO_DIR}/scripts/install.sh"
|