taler-monitoring/site-gen/run-on-firecuda.sh
2026-07-18 13:56:54 +02:00

59 lines
2.1 KiB
Bash
Executable file

#!/usr/bin/env bash
# run-on-firecuda.sh — entrypoint for launchd/cron on firecuda-external.
# Outside-only monitoring (SKIP_SSH=1), all 9 sites, then stage HTML to koopa.
#
# Installed path on firecuda (default):
# ~/taler-monitoring-site-gen/site-gen/run-on-firecuda.sh
#
set -uo pipefail
export PATH="/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:${PATH:-}"
ROOT=$(cd "$(dirname "$0")" && pwd)
LOG_DIR="${FIRECUDA_LOG_DIR:-$HOME/Library/Logs/taler-monitoring-sites}"
mkdir -p "$LOG_DIR"
STAMP=$(date +%Y%m%d-%H%M%S)
LOG="$LOG_DIR/run-${STAMP}.log"
exec >>"$LOG" 2>&1
echo "======== $(date -Iseconds 2>/dev/null || date) firecuda monitoring sites ========"
# Always: public DNS only, no SSH checks into stacks
export SKIP_SSH=1
export CONTINUE_ON_ERROR=1
export AUTH401_CONTINUE=1
export RUNNER_SSH=
export PHASES_ERR="${PHASES_ERR:-urls versions}"
export PHASES_OK="${PHASES_OK:-urls versions}"
export WORK_ROOT="${WORK_ROOT:-$HOME/var/taler-monitoring-sites-work}"
export MONITORING_ROOT="${MONITORING_ROOT:-$ROOT/..}"
export DEPLOY_SSH="${DEPLOY_SSH:-koopa-external}"
export DEPLOY_STAGING="${DEPLOY_STAGING:-/home/hernani/monitoring-sites-staging}"
# Prefer full 9-site list from settings or defaults inside generate script
unset ONLY_HOSTS
cd "$ROOT" || exit 1
chmod +x generate-monitoring-sites.sh deploy-monitoring-sites.sh console_to_html.py 2>/dev/null || true
./generate-monitoring-sites.sh
ec=$?
# HTML stays on firecuda under WORK_ROOT/html.
# Optional push to koopa if this host can SSH there (often only from laptop):
if [ -n "${DEPLOY_SSH:-}" ] && [ "${DEPLOY_FROM_FIRECUDA:-0}" = "1" ]; then
if [ -x ./deploy-monitoring-sites.sh ]; then
./deploy-monitoring-sites.sh || echo "WARN: deploy staging failed"
fi
else
echo "note: HTML at ${WORK_ROOT}/html — pull from laptop:"
echo " rsync -az firecuda-external:var/taler-monitoring-sites-work/html/ \\"
echo " koopa-external:monitoring-sites-staging/"
echo " # or: ./pull-firecuda-to-koopa.sh"
fi
# keep last 20 logs
ls -1t "$LOG_DIR"/run-*.log 2>/dev/null | tail -n +21 | xargs rm -f 2>/dev/null || true
echo "======== done ec=$ec ========"
exit "$ec"