Skip to content

Repository files, collaboration, releases and project activity.

ARCHFORGE HISTORY

Blame · fix-status-branding.sh

Branch main · the Commit author is not necessarily a verified ArchForge account.

2109dd33b8archadmin2026-10-121 #!/usr/bin/env bash
2109dd33b8archadmin2026-10-122 # Safe standalone script: run with `bash ./fix-status-branding.sh` from the Git checkout.
2109dd33b8archadmin2026-10-123 # Do not source this script (it is intentionally a standalone command).
2109dd33b8archadmin2026-10-124 set -Eeuo pipefail
2109dd33b8archadmin2026-10-125 umask 077
2109dd33b8archadmin2026-10-126 error(){ printf '[ERROR] %s\n' "$*" >&2; }
2109dd33b8archadmin2026-10-127 info(){ printf '[INFO] %s\n' "$*"; }
2109dd33b8archadmin2026-10-128 fail(){ error "$*"; return 1; }
2109dd33b8archadmin2026-10-129 trap 'error "Branding repair stopped on line $LINENO; your SQLite database was not erased."' ERR
2109dd33b8archadmin2026-10-1210 
2109dd33b8archadmin2026-10-1211 if [[ $EUID -ne 0 ]]; then error 'Run as root (or sudo bash ./fix-status-branding.sh).'; exit 1; fi
2109dd33b8archadmin2026-10-1212 ROOT=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
2109dd33b8archadmin2026-10-1213 cd "$ROOT"
2109dd33b8archadmin2026-10-1214 if [[ ! -f package.json || ! -f scripts/deploy.sh || ! -f src/branding.js ]]; then
2109dd33b8archadmin2026-10-1215  error 'Missing release files. Push the full External Status 1.0.9 project to Git, then pull it on VPS 2.'
2109dd33b8archadmin2026-10-1216  exit 1
2109dd33b8archadmin2026-10-1217 fi
2109dd33b8archadmin2026-10-1218 if [[ ! -x /usr/bin/node ]]; then error 'Node.js is not installed at /usr/bin/node.'; exit 1; fi
2109dd33b8archadmin2026-10-1219 VERSION=$(/usr/bin/node -p "require('./package.json').version")
2109dd33b8archadmin2026-10-1220 if [[ "$VERSION" != '1.0.9' ]]; then
2109dd33b8archadmin2026-10-1221  error "Your Git checkout is v$VERSION; expected v1.0.9. Upload/commit the new files to ArchForge, git pull, then retry."
2109dd33b8archadmin2026-10-1222  exit 1
2109dd33b8archadmin2026-10-1223 fi
2109dd33b8archadmin2026-10-1224 if ! grep -Fq "label:'ArchForge SSH'" src/probes.js || ! grep -Fq "label:'ArchForge HTTPS'" src/probes.js; then
2109dd33b8archadmin2026-10-1225  error 'Git checkout still contains older probe names. Commit/push/pull all v1.0.9 files.'
2109dd33b8archadmin2026-10-1226  exit 1
2109dd33b8archadmin2026-10-1227 fi
2109dd33b8archadmin2026-10-1228 info 'Deploying verified v1.0.9 source and backing up the existing database...'
2109dd33b8archadmin2026-10-1229 bash "$ROOT/scripts/deploy.sh" "$ROOT"
2109dd33b8archadmin2026-10-1230 INSTALLED=/opt/archforge-status/app
2109dd33b8archadmin2026-10-1231 if [[ ! -f "$INSTALLED/package.json" || ! -f "$INSTALLED/src/branding.js" ]]; then
2109dd33b8archadmin2026-10-1232  error 'The installed application still lacks v1.0.9 files. Inspect systemd and deploy output.'
2109dd33b8archadmin2026-10-1233  exit 1
2109dd33b8archadmin2026-10-1234 fi
2109dd33b8archadmin2026-10-1235 if ! cmp -s "$ROOT/src/database.js" "$INSTALLED/src/database.js" || ! cmp -s "$ROOT/src/branding.js" "$INSTALLED/src/branding.js"; then
2109dd33b8archadmin2026-10-1236  error 'Installed source differs from v1.0.9 checkout. Check deploy location and permissions.'
2109dd33b8archadmin2026-10-1237  exit 1
2109dd33b8archadmin2026-10-1238 fi
2109dd33b8archadmin2026-10-1239 if ! systemctl is-active --quiet archforge-status; then
2109dd33b8archadmin2026-10-1240  error 'archforge-status is not active after deployment. Check journalctl -u archforge-status -n 40.'
2109dd33b8archadmin2026-10-1241  exit 1
2109dd33b8archadmin2026-10-1242 fi
2109dd33b8archadmin2026-10-1243 info 'Checking actual running application (not only the Git checkout)...'
2109dd33b8archadmin2026-10-1244 HEALTH=$(curl --silent --show-error --max-time 6 --fail http://127.0.0.1:3000/healthz) || {
2109dd33b8archadmin2026-10-1245  error 'Local status server does not respond. Check journalctl -u archforge-status -n 40.'
2109dd33b8archadmin2026-10-1246  exit 1
2109dd33b8archadmin2026-10-1247 }
2109dd33b8archadmin2026-10-1248 if ! printf '%s' "$HEALTH" | /usr/bin/node -e 'let t="";process.stdin.on("data",c=>t+=c).on("end",()=>{try{const d=JSON.parse(t);if(d.version!=="1.0.9"||d.ok!==true)process.exit(1)}catch{process.exit(1)}})' ; then
2109dd33b8archadmin2026-10-1249  error "Running status server is NOT v1.0.9. Health response: $HEALTH"
2109dd33b8archadmin2026-10-1250  error 'Check systemctl cat archforge-status and inspect other services on port 3000.'
2109dd33b8archadmin2026-10-1251  exit 1
2109dd33b8archadmin2026-10-1252 fi
2109dd33b8archadmin2026-10-1253 info "Health endpoint confirms $HEALTH"
2109dd33b8archadmin2026-10-1254 if command -v sqlite3 >/dev/null 2>&1 && [[ -f /var/lib/archforge-status/status.db ]]; then
2109dd33b8archadmin2026-10-1255  LABELS=$(sqlite3 -separator '|' /var/lib/archforge-status/status.db \
2109dd33b8archadmin2026-10-1256  "SELECT id,label FROM services WHERE id IN ('git_http','git_ssh') ORDER BY id;")
2109dd33b8archadmin2026-10-1257  printf '[INFO] Persisted labels:\n%s\n' "$LABELS"
2109dd33b8archadmin2026-10-1258  if [[ "$LABELS" == *'Git Smart HTTP'* || "$LABELS" == *'Git SSH'* ]]; then
2109dd33b8archadmin2026-10-1259  error 'Old labels are still in SQLite after successful v1.0.9 boot. Check for an alternate database or another running process.'
2109dd33b8archadmin2026-10-1260  exit 1
2109dd33b8archadmin2026-10-1261  fi
2109dd33b8archadmin2026-10-1262 fi
2109dd33b8archadmin2026-10-1263 info 'Done: new branding is active. Refresh https://status.archforge.nl with Ctrl+F5.'