release 1.10.4: strict suite auto-upgrade; bootstrap monpages ERROR; stage timer units

This commit is contained in:
Hernâni Marques 2026-07-19 01:32:09 +02:00
parent bc0d0a5485
commit 761e3d3c11
No known key found for this signature in database
GPG key ID: CB5738652768F7E9
8 changed files with 143 additions and 25 deletions

View file

@ -1,5 +1,17 @@
#!/usr/bin/env bash
# update-suite.sh — latest taler-monitoring from Forgejo (standalone repo root).
# update-suite.sh — pull latest taler-monitoring from Forgejo (standalone repo root).
#
# Sourced by run-host-report.sh / wrappers. Every host-agent run must land on
# current origin/$SUITE_GIT_REF (default main). Stale clones are not acceptable.
#
# Env:
# SUITE_GIT_URL default https://git.hacktivism.ch/hernani/taler-monitoring.git
# SUITE_GIT_REF default main
# SUITE_DIR default ~/src/taler-monitoring
# SUITE_UPDATE_MODE reset (default) | pull
# SUITE_UPDATE_STRICT 1 (default) = fetch/reset failure aborts the agent run
# 0 = warn and continue on old tree (emergency only)
#
set -uo pipefail
CFG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/taler-monitoring"
ENV_FILE="${TALER_MONITORING_ENV:-$CFG_DIR/env}"
@ -9,31 +21,64 @@ fi
SUITE_GIT_URL="${SUITE_GIT_URL:-https://git.hacktivism.ch/hernani/taler-monitoring.git}"
SUITE_GIT_REF="${SUITE_GIT_REF:-main}"
SUITE_UPDATE_MODE="${SUITE_UPDATE_MODE:-reset}"
SUITE_UPDATE_STRICT="${SUITE_UPDATE_STRICT:-1}"
if [ -z "${SUITE_DIR:-}" ]; then
if [ -d "$HOME/src/taler-monitoring/.git" ]; then SUITE_DIR="$HOME/src/taler-monitoring"
elif [ -d "$HOME/taler-monitoring/.git" ]; then SUITE_DIR="$HOME/taler-monitoring"
else SUITE_DIR="$HOME/src/taler-monitoring"; fi
fi
export SUITE_DIR
_upd_die() {
echo "ERROR suite-update: $*" >&2
if [ "${SUITE_UPDATE_STRICT}" = "1" ]; then
return 1 2>/dev/null || exit 1
fi
echo "WARN suite-update: continuing on existing tree (SUITE_UPDATE_STRICT=0)" >&2
return 0
}
mkdir -p "$(dirname "$SUITE_DIR")" "$CFG_DIR"
if [ ! -d "$SUITE_DIR/.git" ]; then
echo "clone $SUITE_GIT_URL$SUITE_DIR"
git clone --branch "$SUITE_GIT_REF" "$SUITE_GIT_URL" "$SUITE_DIR" || git clone "$SUITE_GIT_URL" "$SUITE_DIR"
if ! git clone --branch "$SUITE_GIT_REF" "$SUITE_GIT_URL" "$SUITE_DIR" \
&& ! git clone "$SUITE_GIT_URL" "$SUITE_DIR"; then
_upd_die "git clone failed"
return 1 2>/dev/null || exit 1
fi
fi
cd "$SUITE_DIR" || exit 1
cd "$SUITE_DIR" || { _upd_die "cd $SUITE_DIR failed"; return 1 2>/dev/null || exit 1; }
git remote set-url origin "$SUITE_GIT_URL" 2>/dev/null || true
echo "fetch origin ($SUITE_GIT_REF) …"
if ! git fetch --tags origin 2>&1; then
echo "WARN: git fetch failed — using existing tree" >&2
return 0 2>/dev/null || exit 0
_before=$(git rev-parse --short=12 HEAD 2>/dev/null || echo none)
_before_ver=$(git describe --tags --exact-match 2>/dev/null \
|| git describe --tags --abbrev=0 2>/dev/null \
|| echo unknown)
echo "fetch origin ($SUITE_GIT_REF) + tags …"
if ! git fetch --tags --force --prune origin 2>&1; then
_upd_die "git fetch failed — suite would stay at ${_before} (${_before_ver})"
# fall through only if STRICT=0
else
case "$SUITE_UPDATE_MODE" in
reset)
if ! git checkout -B "$SUITE_GIT_REF" "origin/$SUITE_GIT_REF" 2>/dev/null \
&& ! git checkout -B "$SUITE_GIT_REF" FETCH_HEAD; then
_upd_die "git checkout $SUITE_GIT_REF failed"
fi
if ! git reset --hard "origin/$SUITE_GIT_REF" 2>/dev/null \
&& ! git reset --hard FETCH_HEAD; then
_upd_die "git reset --hard origin/$SUITE_GIT_REF failed"
fi
;;
*)
if ! git pull --ff-only origin "$SUITE_GIT_REF" 2>&1; then
_upd_die "git pull --ff-only failed"
fi
;;
esac
fi
case "$SUITE_UPDATE_MODE" in
reset)
git checkout -B "$SUITE_GIT_REF" "origin/$SUITE_GIT_REF" 2>/dev/null || git checkout -B "$SUITE_GIT_REF" FETCH_HEAD
git reset --hard "origin/$SUITE_GIT_REF" 2>/dev/null || git reset --hard FETCH_HEAD
;;
*) git pull --ff-only origin "$SUITE_GIT_REF" 2>&1 || true ;;
esac
COMMIT=$(git rev-parse HEAD)
COMMIT_SHORT=$(git rev-parse --short=12 HEAD)
SOURCE_REPO_WEB="${SOURCE_REPO_WEB:-https://git.hacktivism.ch/hernani/taler-monitoring}"
@ -50,13 +95,10 @@ if command -v git >/dev/null 2>&1; then
fi
if [ -z "$SUITE_VERSION" ] && [ -f "$SUITE_DIR/VERSION" ]; then
SUITE_VERSION="v$(tr -d '[:space:]' <"$SUITE_DIR/VERSION" | sed 's/^v//')"
case "$SUITE_VERSION" in v*) ;; *) SUITE_VERSION="v${SUITE_VERSION#v}" ;; esac
fi
[ -z "$SUITE_VERSION" ] && SUITE_VERSION="unknown"
# normalize: ensure leading v for tags
case "$SUITE_VERSION" in
unknown) ;;
v*) ;;
unknown|v*) ;;
*) SUITE_VERSION="v${SUITE_VERSION}" ;;
esac
SUITE_VERSION_URL=""
@ -64,9 +106,22 @@ if [ -n "$SOURCE_REPO_WEB" ] && [ "$SUITE_VERSION" != "unknown" ]; then
SUITE_VERSION_URL="${SOURCE_REPO_WEB}/src/tag/${SUITE_VERSION}"
fi
export SUITE_VERSION SUITE_VERSION_URL
echo " version=$SUITE_VERSION ${SUITE_VERSION_URL:$SUITE_VERSION_URL}"
if [ "$_before" != "$COMMIT_SHORT" ]; then
echo " upgraded ${_before} (${_before_ver}) → ${COMMIT_SHORT} (${SUITE_VERSION})"
else
echo " already at ${COMMIT_SHORT} (${SUITE_VERSION})"
fi
echo " version=$SUITE_VERSION ${SUITE_VERSION_URL:$SUITE_VERSION_URL}"
echo "suite @ $COMMIT_SHORT $COMMIT_URL"
echo " dir=$SUITE_DIR"
# Sanity: must have suite entrypoint after update
if [ ! -x "$SUITE_DIR/taler-monitoring.sh" ] && [ ! -f "$SUITE_DIR/taler-monitoring.sh" ]; then
_upd_die "taler-monitoring.sh missing after update"
return 1 2>/dev/null || exit 1
fi
ln -sfn "$SUITE_DIR" "$HOME/taler-monitoring" 2>/dev/null || true
chmod +x taler-monitoring.sh check_*.sh host-agent/*.sh site-gen/*.sh site-gen/*.py 2>/dev/null || true
return 0 2>/dev/null || true