Skip to content

Repository files, collaboration, releases and project activity.

archforge-external-status / recover-admin.shmain
▤ recover-admin.sh1349 bytes
21 lines · Select a line number for a permalink
1#!/usr/bin/env bash
2# Recover a partially-completed ArchForge External Status installation.
3# Safe on a running server: does not touch status.env, SQLite data, or systemd.
4set -Eeuo pipefail
5umask 077
6[[ $EUID -eq 0 ]] || { echo '[ERROR] Run sudo ./recover-admin.sh (or as root).' >&2; exit 1; }
7SRC=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
8TARGET=/opt/archforge-status/app/src/cli.js
9CFG=/etc/archforge-status/status.env
10[[ -f "$SRC/src/cli.js" ]] || { echo '[ERROR] Cannot find src/cli.js in project directory.' >&2;exit 1; }
11[[ -f "$TARGET" && -f "$CFG" ]] || { echo '[ERROR] External Status is not installed yet. Use sudo ./install.sh instead.' >&2;exit 1; }
12id archforge-status >/dev/null 2>&1 || { echo '[ERROR] Linux service user archforge-status not found.' >&2;exit 1; }
13/usr/bin/node --check "$SRC/src/cli.js"
14# Only the broken CLI file is updated. Running Node.js processes are unchanged.
15install -o root -g root -m 644 "$SRC/src/cli.js" "$TARGET"
16cd /opt/archforge-status/app
17printf '%s\n' '[*] Admin recovery: prompts for password will accept typing without displaying characters.'
18runuser -u archforge-status -- env STATUS_ENV_FILE="$CFG" NODE_ENV=production /usr/bin/node src/cli.js create-admin
19printf '%s\n' '[OK] Admin setup finished (or an admin already existed).'
20echo 'Login: https://status.archforge.nl/admin/login'