fix 1.23.7: FP stage host-agent install and tip parity with GOA

Ship fp-stage systemd units; install-host-agent.sh --fp-stage for stagepaysan
(disables GOA timers on FP host). Env example enforces SUITE_REQUIRE_REMOTE_TIP.
This commit is contained in:
Hernâni Marques 2026-07-22 03:54:09 +02:00
parent 52db4acace
commit 2451c66173
No known key found for this signature in database
7 changed files with 158 additions and 11 deletions

View file

@ -1,20 +1,118 @@
#!/usr/bin/env bash
# install-host-agent.sh — install hernani user systemd units on koopa
# install-host-agent.sh — install user systemd mon units
#
# # on koopa as hernani:
# # GOA / koopa as hernani (default):
# ~/src/taler-monitoring/host-agent/install-host-agent.sh
# # or from laptop:
# # FrancPaysan stage as stagepaysan:
# ~/src/taler-monitoring/host-agent/install-host-agent.sh --fp-stage
# # from laptop:
# ./install-host-agent.sh --remote $DEPLOY_SSH
# ./install-host-agent.sh --remote $DEPLOY_SSH --fp-stage
#
# Suite tree is ONLY ~/src/taler-monitoring (standalone repo). No koopa-admin-log.
# Both stacks share run-host-report.sh → update-suite tip enforcement + per-dir publish.
#
set -euo pipefail
ROOT=$(cd "$(dirname "$0")" && pwd)
REMOTE="${1:-}"
[ "${1:-}" = "--remote" ] && REMOTE="${2:-${DEPLOY_SSH:-}}"
REMOTE=""
STACK="${HOST_AGENT_STACK:-goa}"
while [ $# -gt 0 ]; do
case "$1" in
--remote)
REMOTE="${2:-${DEPLOY_SSH:-}}"
shift 2
;;
--fp-stage|--fp|--stagepaysan)
STACK=fp-stage
shift
;;
--goa|goa)
STACK=goa
shift
;;
*)
# bare host = remote (legacy)
if [ -z "$REMOTE" ] && [ "$1" != "--remote" ]; then
REMOTE="$1"
fi
shift
;;
esac
done
SUITE_URL="${SUITE_GIT_URL:-https://git.hacktivism.ch/hernani/taler-monitoring.git}"
install_fp_stage() {
local mon home_unit
mon=$(cd "$ROOT/.." && pwd)
if [ -d "$HOME/src/taler-monitoring/.git" ] || [ -d "$HOME/src/taler-monitoring" ]; then
mon="$HOME/src/taler-monitoring"
fi
home_unit="$HOME/.config/systemd/user"
mkdir -p "$home_unit" \
"$HOME/.local/state/taler-monitoring-stage-lfp" \
"$HOME/monitoring-sites-staging" \
"$HOME/.config/taler-monitoring" \
"$HOME/src"
if [ ! -f "$HOME/.config/taler-monitoring/env" ] && [ -f "$ROOT/env/stagepaysan.env.example" ]; then
cp "$ROOT/env/stagepaysan.env.example" "$HOME/.config/taler-monitoring/env"
echo "created ~/.config/taler-monitoring/env from stagepaysan.env.example"
fi
# Ensure tip-enforcement knobs present (idempotent append if missing)
if [ -f "$HOME/.config/taler-monitoring/env" ]; then
grep -q '^SUITE_UPDATE_MODE=' "$HOME/.config/taler-monitoring/env" 2>/dev/null \
|| echo 'SUITE_UPDATE_MODE=reset' >>"$HOME/.config/taler-monitoring/env"
grep -q '^SUITE_UPDATE_STRICT=' "$HOME/.config/taler-monitoring/env" 2>/dev/null \
|| echo 'SUITE_UPDATE_STRICT=1' >>"$HOME/.config/taler-monitoring/env"
grep -q '^SUITE_REQUIRE_REMOTE_TIP=' "$HOME/.config/taler-monitoring/env" 2>/dev/null \
|| echo 'SUITE_REQUIRE_REMOTE_TIP=1' >>"$HOME/.config/taler-monitoring/env"
fi
if [ ! -d "$HOME/src/taler-monitoring/.git" ]; then
echo "clone $SUITE_URL$HOME/src/taler-monitoring"
git clone "$SUITE_URL" "$HOME/src/taler-monitoring" \
|| echo "WARN: clone failed — using tree at $mon if present"
fi
mon="$HOME/src/taler-monitoring"
ln -sfn "$mon" "$HOME/taler-monitoring" 2>/dev/null || true
(
cd "$mon"
git fetch --tags --force --prune origin 2>/dev/null || true
git checkout -B main origin/main 2>/dev/null || git checkout main 2>/dev/null || true
git reset --hard origin/main 2>/dev/null || true
)
chmod +x "$mon"/taler-monitoring.sh "$mon"/check_*.sh 2>/dev/null || true
chmod +x "$mon/host-agent"/*.sh 2>/dev/null || true
chmod +x "$mon/site-gen"/*.sh "$mon/site-gen/console_to_html.py" 2>/dev/null || true
install -m 644 "$ROOT/taler-monitoring-fp-stage.service" "$home_unit/"
install -m 644 "$ROOT/taler-monitoring-fp-stage.timer" "$home_unit/"
chmod +x "$ROOT/run-fp-stage-monitoring.sh" 2>/dev/null || true
# FP host must not run GOA timers (would write GOA mon dirs / wrong inventory)
for u in taler-monitoring-hacktivism taler-monitoring-surface \
taler-monitoring-aptdeploy taler-monitoring-max-ladder \
taler-monitoring-mail taler-monitoring-mattermost; do
systemctl --user disable --now "${u}.timer" 2>/dev/null || true
systemctl --user disable --now "${u}.path" 2>/dev/null || true
systemctl --user stop "${u}.service" 2>/dev/null || true
rm -f "$home_unit/${u}.service" "$home_unit/${u}.timer" "$home_unit/${u}.path" 2>/dev/null || true
done
systemctl --user daemon-reload
systemctl --user enable --now taler-monitoring-fp-stage.timer
systemctl --user start --no-block taler-monitoring-fp-stage.service || true
echo "--- FP stage status ---"
systemctl --user status taler-monitoring-fp-stage.timer --no-pager -l | head -12 || true
systemctl --user list-timers --all | grep taler-monitoring || true
echo "OK host-agent FP stage:"
echo " · fp-stage 4h → /monitoring on stage.{bank,exchange,monnaie}.lefrancpaysan.ch"
echo " · suite tip: $mon (SUITE_REQUIRE_REMOTE_TIP=1 via run-host-report)"
echo "manual: systemctl --user start taler-monitoring-fp-stage.service"
}
install_local() {
local mon home_unit
mon=$(cd "$ROOT/.." && pwd)
@ -115,7 +213,7 @@ install_local() {
}
if [ -n "$REMOTE" ] && [ "$REMOTE" != "--remote" ]; then
echo "install on $REMOTE"
echo "install on $REMOTE (stack=$STACK)"
# ROOT = …/taler-monitoring/host-agent → suite root is parent
rsync -az --delete \
--exclude secrets.env \
@ -123,8 +221,17 @@ if [ -n "$REMOTE" ] && [ "$REMOTE" != "--remote" ]; then
--exclude '.git' \
"$ROOT/../" \
"${REMOTE}:src/taler-monitoring/"
ssh -o BatchMode=yes "$REMOTE" \
'bash $HOME/src/taler-monitoring/host-agent/install-host-agent.sh'
if [ "$STACK" = "fp-stage" ]; then
ssh -o BatchMode=yes "$REMOTE" \
'bash $HOME/src/taler-monitoring/host-agent/install-host-agent.sh --fp-stage'
else
ssh -o BatchMode=yes "$REMOTE" \
'bash $HOME/src/taler-monitoring/host-agent/install-host-agent.sh'
fi
else
install_local
if [ "$STACK" = "fp-stage" ]; then
install_fp_stage
else
install_local
fi
fi