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-12
1 #!/usr/bin/env bash2109dd33b8archadmin2026-10-12
2 # Safe standalone script: run with `bash ./fix-status-branding.sh` from the Git checkout.2109dd33b8archadmin2026-10-12
3 # Do not source this script (it is intentionally a standalone command).2109dd33b8archadmin2026-10-12
4 set -Eeuo pipefail2109dd33b8archadmin2026-10-12
5 umask 0772109dd33b8archadmin2026-10-12
6 error(){ printf '[ERROR] %s\n' "$*" >&2; }2109dd33b8archadmin2026-10-12
7 info(){ printf '[INFO] %s\n' "$*"; }2109dd33b8archadmin2026-10-12
8 fail(){ error "$*"; return 1; }2109dd33b8archadmin2026-10-12
9 trap 'error "Branding repair stopped on line $LINENO; your SQLite database was not erased."' ERR2109dd33b8archadmin2026-10-12
10 2109dd33b8archadmin2026-10-12
11 if [[ $EUID -ne 0 ]]; then error 'Run as root (or sudo bash ./fix-status-branding.sh).'; exit 1; fi2109dd33b8archadmin2026-10-12
12 ROOT=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)2109dd33b8archadmin2026-10-12
13 cd "$ROOT"2109dd33b8archadmin2026-10-12
14 if [[ ! -f package.json || ! -f scripts/deploy.sh || ! -f src/branding.js ]]; then2109dd33b8archadmin2026-10-12
15 error 'Missing release files. Push the full External Status 1.0.9 project to Git, then pull it on VPS 2.'2109dd33b8archadmin2026-10-12
16 exit 12109dd33b8archadmin2026-10-12
17 fi2109dd33b8archadmin2026-10-12
18 if [[ ! -x /usr/bin/node ]]; then error 'Node.js is not installed at /usr/bin/node.'; exit 1; fi2109dd33b8archadmin2026-10-12
19 VERSION=$(/usr/bin/node -p "require('./package.json').version")2109dd33b8archadmin2026-10-12
20 if [[ "$VERSION" != '1.0.9' ]]; then2109dd33b8archadmin2026-10-12
21 error "Your Git checkout is v$VERSION; expected v1.0.9. Upload/commit the new files to ArchForge, git pull, then retry."2109dd33b8archadmin2026-10-12
22 exit 12109dd33b8archadmin2026-10-12
23 fi2109dd33b8archadmin2026-10-12
24 if ! grep -Fq "label:'ArchForge SSH'" src/probes.js || ! grep -Fq "label:'ArchForge HTTPS'" src/probes.js; then2109dd33b8archadmin2026-10-12
25 error 'Git checkout still contains older probe names. Commit/push/pull all v1.0.9 files.'2109dd33b8archadmin2026-10-12
26 exit 12109dd33b8archadmin2026-10-12
27 fi2109dd33b8archadmin2026-10-12
28 info 'Deploying verified v1.0.9 source and backing up the existing database...'2109dd33b8archadmin2026-10-12
29 bash "$ROOT/scripts/deploy.sh" "$ROOT"2109dd33b8archadmin2026-10-12
30 INSTALLED=/opt/archforge-status/app2109dd33b8archadmin2026-10-12
31 if [[ ! -f "$INSTALLED/package.json" || ! -f "$INSTALLED/src/branding.js" ]]; then2109dd33b8archadmin2026-10-12
32 error 'The installed application still lacks v1.0.9 files. Inspect systemd and deploy output.'2109dd33b8archadmin2026-10-12
33 exit 12109dd33b8archadmin2026-10-12
34 fi2109dd33b8archadmin2026-10-12
35 if ! cmp -s "$ROOT/src/database.js" "$INSTALLED/src/database.js" || ! cmp -s "$ROOT/src/branding.js" "$INSTALLED/src/branding.js"; then2109dd33b8archadmin2026-10-12
36 error 'Installed source differs from v1.0.9 checkout. Check deploy location and permissions.'2109dd33b8archadmin2026-10-12
37 exit 12109dd33b8archadmin2026-10-12
38 fi2109dd33b8archadmin2026-10-12
39 if ! systemctl is-active --quiet archforge-status; then2109dd33b8archadmin2026-10-12
40 error 'archforge-status is not active after deployment. Check journalctl -u archforge-status -n 40.'2109dd33b8archadmin2026-10-12
41 exit 12109dd33b8archadmin2026-10-12
42 fi2109dd33b8archadmin2026-10-12
43 info 'Checking actual running application (not only the Git checkout)...'2109dd33b8archadmin2026-10-12
44 HEALTH=$(curl --silent --show-error --max-time 6 --fail http://127.0.0.1:3000/healthz) || {2109dd33b8archadmin2026-10-12
45 error 'Local status server does not respond. Check journalctl -u archforge-status -n 40.'2109dd33b8archadmin2026-10-12
46 exit 12109dd33b8archadmin2026-10-12
47 }2109dd33b8archadmin2026-10-12
48 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)}})' ; then2109dd33b8archadmin2026-10-12
49 error "Running status server is NOT v1.0.9. Health response: $HEALTH"2109dd33b8archadmin2026-10-12
50 error 'Check systemctl cat archforge-status and inspect other services on port 3000.'2109dd33b8archadmin2026-10-12
51 exit 12109dd33b8archadmin2026-10-12
52 fi2109dd33b8archadmin2026-10-12
53 info "Health endpoint confirms $HEALTH"2109dd33b8archadmin2026-10-12
54 if command -v sqlite3 >/dev/null 2>&1 && [[ -f /var/lib/archforge-status/status.db ]]; then2109dd33b8archadmin2026-10-12
55 LABELS=$(sqlite3 -separator '|' /var/lib/archforge-status/status.db \2109dd33b8archadmin2026-10-12
56 "SELECT id,label FROM services WHERE id IN ('git_http','git_ssh') ORDER BY id;")2109dd33b8archadmin2026-10-12
57 printf '[INFO] Persisted labels:\n%s\n' "$LABELS"2109dd33b8archadmin2026-10-12
58 if [[ "$LABELS" == *'Git Smart HTTP'* || "$LABELS" == *'Git SSH'* ]]; then2109dd33b8archadmin2026-10-12
59 error 'Old labels are still in SQLite after successful v1.0.9 boot. Check for an alternate database or another running process.'2109dd33b8archadmin2026-10-12
60 exit 12109dd33b8archadmin2026-10-12
61 fi2109dd33b8archadmin2026-10-12
62 fi2109dd33b8archadmin2026-10-12
63 info 'Done: new branding is active. Refresh https://status.archforge.nl with Ctrl+F5.'