install.sh 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  1. #!/bin/sh
  2. # =============================================================================
  3. # NetPulse — one-liner installer (Linux server)
  4. #
  5. # Read-only PWA dashboard for monitoring OpenWrt/GL.iNet home networks.
  6. # Installs the single static Go binary (frontend embedded) as a sandboxed
  7. # systemd service.
  8. #
  9. # Usage:
  10. # curl -fsSL https://raw.githubusercontent.com/gnacho/netpulse/main/install.sh | sh
  11. # sh install.sh --version=1.0.0 --unattended
  12. # sh install.sh --dry-run # describe every step, touches nothing
  13. # sh install.sh --uninstall # keeps /var/lib/netpulse (data + .env)
  14. # sh install.sh --uninstall --purge
  15. #
  16. # Requirements: Linux with systemd (Debian/Ubuntu/Fedora/Arch/...),
  17. # amd64 / arm64 / armv7. Verifies sha256 of every download (checksums.txt).
  18. #
  19. # Layout (capistrano-less: single binary + state dir):
  20. # /usr/local/bin/netpulse binary
  21. # /var/lib/netpulse working dir: .env, data/ (SQLite), .ssh/
  22. # =============================================================================
  23. set -eu
  24. APP_NAME="netpulse"
  25. GH_REPO="gnacho/netpulse"
  26. BIN_NAME="netpulse"
  27. DEFAULT_PORT="3000"
  28. INSTALL_DIR="/usr/local/bin"
  29. STATE_DIR="/var/lib/$APP_NAME"
  30. SERVICE_NAME="$APP_NAME"
  31. NETPULSE_VERSION=""; UNATTENDED=0; DRY_RUN=0; UNINSTALL=0; PURGE=0; DEMO=0
  32. # ---------------------------------------------------------------- logging ---
  33. if [ -t 1 ] && [ -z "${NO_COLOR:-}" ]; then
  34. C_G=$(printf '\033[32m'); C_R=$(printf '\033[31m'); C_Y=$(printf '\033[33m'); C_B=$(printf '\033[1m'); C_0=$(printf '\033[0m')
  35. else C_G=""; C_R=""; C_Y=""; C_B=""; C_0=""; fi
  36. info() { printf '%s--%s %s\n' "$C_B" "$C_0" "$*"; }
  37. ok() { printf '%s✓%s %s\n' "$C_G" "$C_0" "$*"; }
  38. warn() { printf '%s!%s %s\n' "$C_Y" "$C_0" "$*" >&2; }
  39. err() { printf '%s✗ %s%s\n' "$C_R" "$*" "$C_0" >&2; }
  40. fatal() { _c=$1; shift; err "$*"; exit "$_c"; }
  41. run() { if [ "$DRY_RUN" -eq 1 ]; then info "[dry-run] $*"; else "$@"; fi; }
  42. usage() {
  43. cat <<EOF
  44. NetPulse — installer (network monitoring dashboard for OpenWrt/GL.iNet)
  45. Usage: sh install.sh [options]
  46. --version=X.Y.Z version to install (default: latest stable release)
  47. --demo install in demo mode with sample data (DEMO_MODE=1)
  48. --unattended no questions (automatic when there's no TTY)
  49. --dry-run describe each step without touching the system
  50. --uninstall remove service, binary and user (keeps $STATE_DIR)
  51. --purge with --uninstall: also remove data and configuration
  52. -h, --help this help
  53. Update = re-run this script (your data and .env are preserved).
  54. Repo: https://github.com/$GH_REPO
  55. EOF
  56. exit 0
  57. }
  58. for arg in "$@"; do
  59. case "$arg" in
  60. --version=*) NETPULSE_VERSION="${arg#*=}" ;;
  61. --demo) DEMO=1 ;;
  62. --unattended) UNATTENDED=1 ;;
  63. --dry-run) DRY_RUN=1 ;;
  64. --uninstall) UNINSTALL=1 ;;
  65. --purge) PURGE=1 ;;
  66. -h|--help) usage ;;
  67. *) fatal 10 "unknown option: $arg (try --help)" ;;
  68. esac
  69. done
  70. [ -t 0 ] || UNATTENDED=1 # pipe-to-shell: never prompt
  71. # ------------------------------------------------------- interactive helpers -
  72. tty_ok() { (exec 3<>/dev/tty) 2>/dev/null; }
  73. # ask_yes_no "question" [default: 0=no, 1=yes] — prompts on /dev/tty; returns 0/1.
  74. # Non-interactive (--unattended or no TTY): returns the default silently.
  75. ask_yes_no() {
  76. _q=$1; _def=${2:-0}
  77. [ "$UNATTENDED" -eq 1 ] && return "$_def"
  78. tty_ok || return "$_def"
  79. if [ "$_def" -eq 1 ]; then _hint="Y/n"; else _hint="y/N"; fi
  80. while :; do
  81. printf '%s [%s] ' "$_q" "$_hint" > /dev/tty
  82. IFS= read -r _r < /dev/tty || _r=""
  83. case "$(printf '%s' "$_r" | tr '[:upper:]' '[:lower:]')" in
  84. "") return "$_def" ;;
  85. y|yes|s|si) return 0 ;;
  86. n|no) return 1 ;;
  87. *) printf 'Please answer y or n.\n' > /dev/tty ;;
  88. esac
  89. done
  90. }
  91. # -------------------------------------------------------------- elevation ---
  92. if [ "$(id -u)" -eq 0 ]; then SUDO=""
  93. elif command -v sudo >/dev/null 2>&1; then SUDO="sudo -E"
  94. elif command -v doas >/dev/null 2>&1; then SUDO="doas"
  95. else fatal 22 "I need root (or sudo/doas). Download the script and run it as root: su -c 'sh install.sh'"
  96. fi
  97. # --------------------------------------------------------------- uninstall --
  98. if [ "$UNINSTALL" -eq 1 ]; then
  99. info "uninstalling $APP_NAME"
  100. if [ -f "/etc/systemd/system/$SERVICE_NAME.service" ]; then
  101. run $SUDO systemctl stop "$SERVICE_NAME" 2>/dev/null || true
  102. run $SUDO systemctl disable "$SERVICE_NAME" 2>/dev/null || true
  103. run $SUDO rm -f "/etc/systemd/system/$SERVICE_NAME.service"
  104. # Units de reinicio bajo demanda (issue #4): si existen, quitarlas
  105. if [ -f "/etc/systemd/system/$SERVICE_NAME-restart.path" ]; then
  106. run $SUDO systemctl disable --now "$SERVICE_NAME-restart.path" 2>/dev/null || true
  107. run $SUDO rm -f "/etc/systemd/system/$SERVICE_NAME-restart.path" \
  108. "/etc/systemd/system/$SERVICE_NAME-restart.service"
  109. fi
  110. run $SUDO systemctl daemon-reload
  111. ok "systemd unit removed"
  112. fi
  113. run $SUDO rm -f "$INSTALL_DIR/$BIN_NAME" "$INSTALL_DIR/$BIN_NAME.bak"
  114. ok "binary removed from $INSTALL_DIR"
  115. if id "$APP_NAME" >/dev/null 2>&1; then
  116. run $SUDO userdel "$APP_NAME" 2>/dev/null || warn "could not delete user $APP_NAME"
  117. ok "system user removed"
  118. fi
  119. if [ "$PURGE" -eq 1 ]; then
  120. run $SUDO rm -rf "$STATE_DIR"
  121. ok "data and configuration removed (--purge)"
  122. else
  123. info "data kept in $STATE_DIR (remove with --purge)"
  124. fi
  125. ok "$APP_NAME uninstalled"
  126. exit 0
  127. fi
  128. # --------------------------------------------------------------- detection --
  129. . /etc/os-release 2>/dev/null || true
  130. OS_PRETTY="${PRETTY_NAME:-$(uname -s)}"
  131. ARCH=$(uname -m)
  132. case "$ARCH" in
  133. x86_64|amd64) GOARCH=amd64 ;;
  134. aarch64|arm64) GOARCH=arm64 ;;
  135. armv7l|armv7) GOARCH=armv7 ;;
  136. *) fatal 20 "unsupported architecture: $ARCH (released: amd64, arm64, armv7)"
  137. esac
  138. if [ ! -d /run/systemd/system ] || ! command -v systemctl >/dev/null 2>&1; then
  139. fatal 23 "NetPulse needs systemd (this machine doesn't run it). See https://github.com/$GH_REPO for manual setup"
  140. fi
  141. info "detected: $OS_PRETTY · linux/$GOARCH · systemd"
  142. if command -v curl >/dev/null 2>&1; then FETCH="curl -fsSL --retry 3 --connect-timeout 10"
  143. elif command -v wget >/dev/null 2>&1; then FETCH="wget -q -O-"
  144. else fatal 21 "I need curl or wget (install it with your package manager)"
  145. fi
  146. fetch_to() { $FETCH "$1" > "$2"; }
  147. command -v sha256sum >/dev/null 2>&1 || fatal 21 "missing sha256sum (coreutils package)"
  148. # ------------------------------------------------- disk / memory pre-flight --
  149. AVAIL_MB=$(df -Pm / 2>/dev/null | awk 'NR==2 {print $4}' || true)
  150. if [ -n "${AVAIL_MB:-}" ]; then
  151. [ "$AVAIL_MB" -lt 150 ] && fatal 24 "not enough disk space: ${AVAIL_MB} MB free (minimum 150 MB)"
  152. [ "$AVAIL_MB" -lt 300 ] && warn "low disk space: ${AVAIL_MB} MB free (recommended: 300+ MB)"
  153. ok "disk space: ${AVAIL_MB} MB free"
  154. fi
  155. MEM_MB=$(awk '/^MemAvailable:/ {print int($2/1024)}' /proc/meminfo 2>/dev/null || true)
  156. if [ -n "${MEM_MB:-}" ] && [ "$MEM_MB" -lt 128 ]; then
  157. warn "low memory: ${MEM_MB} MB available — NetPulse needs very little, but 128+ MB is recommended"
  158. fi
  159. # ------------------------------------------------------ port pre-flight -----
  160. port_in_use() {
  161. if command -v ss >/dev/null 2>&1; then
  162. ss -tln 2>/dev/null | awk '{print $4}' | grep -qE "[:.]${1}\$"
  163. elif command -v netstat >/dev/null 2>&1; then
  164. netstat -tln 2>/dev/null | awk '{print $4}' | grep -qE "[:.]${1}\$"
  165. else
  166. return 1 # can't check: assume free
  167. fi
  168. }
  169. pick_port() {
  170. _p=$1; _end=$((_p + 20))
  171. while [ "$_p" -le "$_end" ]; do
  172. if ! port_in_use "$_p"; then printf '%s' "$_p"; return 0; fi
  173. _p=$((_p + 1))
  174. done
  175. return 1
  176. }
  177. # choose_port WANT — interactive (TTY): asks which port to use, suggesting the
  178. # next free one and rejecting busy/invalid answers. Non-interactive: prints the
  179. # next free port. Prints the chosen port on stdout; fails if none is free.
  180. choose_port() {
  181. _want=$1
  182. _next=$(pick_port "$((_want + 1))") || _next=""
  183. if [ "$UNATTENDED" -eq 0 ] && tty_ok; then
  184. while :; do
  185. printf 'Port %s is already in use.\nWhich port should %s listen on? [%s] ' \
  186. "$_want" "$APP_NAME" "${_next:-none free}" > /dev/tty
  187. IFS= read -r _r < /dev/tty || _r=""
  188. _r="${_r:-$_next}"
  189. case "$_r" in
  190. ''|*[!0-9]*) printf 'Please enter a port number.\n' > /dev/tty; continue ;;
  191. esac
  192. if [ "$_r" -lt 1 ] || [ "$_r" -gt 65535 ]; then
  193. printf 'Out of range (1-65535).\n' > /dev/tty; continue
  194. fi
  195. if port_in_use "$_r"; then
  196. printf 'Port %s is also in use.\n' "$_r" > /dev/tty; continue
  197. fi
  198. printf '%s' "$_r"; return 0
  199. done
  200. fi
  201. [ -n "$_next" ] || return 1
  202. printf '%s' "$_next"
  203. }
  204. # Fresh install only: an upgrade keeps the port from the existing .env file.
  205. PORT="$DEFAULT_PORT"
  206. if [ ! -f "$STATE_DIR/.env" ]; then
  207. if port_in_use "$DEFAULT_PORT"; then
  208. PORT=$(choose_port "$DEFAULT_PORT") \
  209. || fatal 25 "port $DEFAULT_PORT is busy and no free port found in $((DEFAULT_PORT + 1))-$((DEFAULT_PORT + 21)) — set one manually in $STATE_DIR/.env after install"
  210. warn "port $DEFAULT_PORT is already in use — NetPulse will listen on $PORT instead"
  211. else
  212. ok "port $DEFAULT_PORT is free"
  213. fi
  214. fi
  215. # Demo mode (issue #4): solo con --demo explícito. El default es BD limpia;
  216. # la demo se activa después desde Ajustes (el botón llama a
  217. # POST /api/demo/enable y reinicia el servicio vía .restart-me).
  218. # --------------------------------------------------------- resolve version --
  219. if [ -z "$NETPULSE_VERSION" ]; then
  220. info "resolving latest stable version"
  221. NETPULSE_VERSION=$($FETCH "https://api.github.com/repos/$GH_REPO/releases/latest" \
  222. | grep '"tag_name"' | head -1 | cut -d'"' -f4) \
  223. || fatal 31 "could not resolve the latest version (GitHub rate-limit?). Use --version=X.Y.Z"
  224. [ -n "$NETPULSE_VERSION" ] || fatal 31 "no stable release found yet. Use --version=X.Y.Z"
  225. fi
  226. VERSION_NORM=$(echo "$NETPULSE_VERSION" | sed 's/^v//')
  227. case "$NETPULSE_VERSION" in
  228. v*) NETPULSE_TAG="$NETPULSE_VERSION" ;;
  229. *) NETPULSE_TAG="v$NETPULSE_VERSION" ;;
  230. esac
  231. ASSET="${BIN_NAME}_${VERSION_NORM}_linux_${GOARCH}.tar.gz"
  232. BASE_URL="https://github.com/$GH_REPO/releases/download/$NETPULSE_TAG"
  233. info "version: $NETPULSE_VERSION"
  234. # connectivity pre-flight BEFORE touching the system
  235. $FETCH "https://github.com/$GH_REPO" >/dev/null \
  236. || fatal 30 "no access to github.com (proxy? DNS? firewall?)"
  237. UPGRADING=0
  238. if [ -x "$INSTALL_DIR/$BIN_NAME" ]; then
  239. UPGRADING=1
  240. info "previous install detected: upgrade mode (data and .env are preserved)"
  241. fi
  242. # ---------------------------------------------------------- download+verify --
  243. TMP=$(mktemp -d) || fatal 34 "mktemp failed"
  244. cleanup() { rm -rf "$TMP"; return 0; }
  245. trap cleanup EXIT INT TERM
  246. info "downloading $ASSET"
  247. fetch_to "$BASE_URL/$ASSET" "$TMP/$ASSET" || fatal 32 "download failed: $BASE_URL/$ASSET"
  248. fetch_to "$BASE_URL/checksums.txt" "$TMP/checksums.txt" || fatal 32 "checksums.txt not found in release $NETPULSE_VERSION"
  249. [ -s "$TMP/$ASSET" ] || fatal 32 "downloaded asset is empty"
  250. SUM_FILE=$(sha256sum "$TMP/$ASSET" | awk '{print $1}')
  251. SUM_REF=$(grep " $ASSET\$" "$TMP/checksums.txt" | awk '{print $1}')
  252. [ -n "$SUM_REF" ] || fatal 33 "$ASSET not listed in checksums.txt"
  253. [ "$SUM_FILE" = "$SUM_REF" ] || fatal 33 "sha256 MISMATCH for $ASSET — corrupt or tampered download"
  254. ok "sha256 verified"
  255. tar -tzf "$TMP/$ASSET" >/dev/null 2>&1 || fatal 34 "tarball is corrupt"
  256. tar -xzf "$TMP/$ASSET" -C "$TMP"
  257. [ -s "$TMP/$BIN_NAME" ] || fatal 34 "tarball does not contain $BIN_NAME"
  258. # ------------------------------------------------------------------ install --
  259. run $SUDO install -d -m 0755 "$INSTALL_DIR"
  260. if [ "$UPGRADING" -eq 1 ]; then
  261. run $SUDO cp -a "$INSTALL_DIR/$BIN_NAME" "$INSTALL_DIR/$BIN_NAME.bak"
  262. info "previous binary backed up: $INSTALL_DIR/$BIN_NAME.bak"
  263. fi
  264. run $SUDO install -T -m 0755 "$TMP/$BIN_NAME" "$INSTALL_DIR/$BIN_NAME"
  265. ok "binary installed at $INSTALL_DIR/$BIN_NAME"
  266. if ! id "$APP_NAME" >/dev/null 2>&1; then
  267. run $SUDO useradd --system --home-dir "$STATE_DIR" --shell /usr/sbin/nologin "$APP_NAME"
  268. ok "system user $APP_NAME created"
  269. fi
  270. run $SUDO install -d -m 0750 -o "$APP_NAME" -g "$APP_NAME" "$STATE_DIR"
  271. # SELinux: context fix, degrade to warning
  272. if command -v getenforce >/dev/null 2>&1 && [ "$(getenforce)" = "Enforcing" ]; then
  273. run $SUDO chcon -t bin_t "$INSTALL_DIR/$BIN_NAME" 2>/dev/null \
  274. || warn "SELinux Enforcing: if the service fails, check 'ausearch -m avc -ts recent'"
  275. fi
  276. # Initial config ONLY on fresh install (upgrades never touch .env or data)
  277. if [ ! -f "$STATE_DIR/.env" ]; then
  278. ADMIN_PASS=$(head -c 18 /dev/urandom | base64 | tr -d '/+=' | head -c 16)
  279. if [ "$DRY_RUN" -eq 1 ]; then info "[dry-run] would generate $STATE_DIR/.env (0600, random admin password, PORT=$PORT, DEMO_MODE=$DEMO)"; else
  280. $SUDO tee "$STATE_DIR/.env" >/dev/null <<EOF
  281. PORT=$PORT
  282. DATA_DIR=./data
  283. AUTH_USER=admin
  284. AUTH_PASS=$ADMIN_PASS
  285. DEMO_MODE=$DEMO
  286. SSH_KEY_PATH=$STATE_DIR/.ssh/id_ed25519
  287. EOF
  288. $SUDO chmod 0600 "$STATE_DIR/.env"
  289. $SUDO chown "$APP_NAME:$APP_NAME" "$STATE_DIR/.env"
  290. fi
  291. FRESH_CREDENTIALS=1
  292. else
  293. FRESH_CREDENTIALS=0
  294. PORT=$(sed -n 's/^PORT=//p' "$STATE_DIR/.env" | head -1)
  295. PORT="${PORT:-$DEFAULT_PORT}"
  296. DEMO=$(sed -n 's/^DEMO_MODE=//p' "$STATE_DIR/.env" | head -1)
  297. DEMO="${DEMO:-0}"
  298. info "existing config kept ($STATE_DIR/.env)"
  299. fi
  300. # ----------------------------------------------------------------- service --
  301. if [ "$DRY_RUN" -eq 1 ]; then info "[dry-run] would write systemd unit + enable --now"; else
  302. $SUDO tee "/etc/systemd/system/$SERVICE_NAME.service" >/dev/null <<EOF
  303. [Unit]
  304. Description=NetPulse — network monitoring dashboard (OpenWrt/GL.iNet)
  305. After=network-online.target
  306. Wants=network-online.target
  307. [Service]
  308. Type=simple
  309. User=$APP_NAME
  310. Group=$APP_NAME
  311. WorkingDirectory=$STATE_DIR
  312. ExecStart=$INSTALL_DIR/$BIN_NAME
  313. Restart=on-failure
  314. RestartSec=5
  315. NoNewPrivileges=true
  316. ProtectSystem=strict
  317. ProtectHome=read-only
  318. PrivateTmp=true
  319. LockPersonality=true
  320. RemoveIPC=true
  321. StateDirectory=$APP_NAME
  322. UMask=007
  323. [Install]
  324. WantedBy=multi-user.target
  325. EOF
  326. # Unidad de reinicio bajo demanda (issue #4 + updater): una unit .path
  327. # vigila $STATE_DIR/data/.restart-me; cuando el servidor lo toca (p.ej.
  328. # POST /api/demo/enable) este oneshot lo borra y reinicia el servicio.
  329. $SUDO tee "/etc/systemd/system/$SERVICE_NAME-restart.path" >/dev/null <<EOF
  330. [Unit]
  331. Description=Reinicia $SERVICE_NAME cuando el servidor toca .restart-me
  332. [Path]
  333. PathChanged=$STATE_DIR/data/.restart-me
  334. [Install]
  335. WantedBy=multi-user.target
  336. EOF
  337. $SUDO tee "/etc/systemd/system/$SERVICE_NAME-restart.service" >/dev/null <<EOF
  338. [Unit]
  339. Description=Reinicio de $SERVICE_NAME solicitado por el servidor
  340. [Service]
  341. Type=oneshot
  342. ExecStart=/bin/sh -c "rm -f $STATE_DIR/data/.restart-me; /bin/systemctl restart $SERVICE_NAME.service"
  343. EOF
  344. fi
  345. run $SUDO systemctl daemon-reload
  346. if [ "$UPGRADING" -eq 1 ]; then run $SUDO systemctl restart "$SERVICE_NAME"
  347. else run $SUDO systemctl enable --now "$SERVICE_NAME"; fi
  348. run $SUDO systemctl enable --now "$SERVICE_NAME-restart.path" 2>/dev/null \
  349. || warn "could not enable $SERVICE_NAME-restart.path (demo/update auto-restart)"
  350. if [ "$DRY_RUN" -eq 0 ]; then
  351. sleep 3
  352. if ! $SUDO systemctl is-active --quiet "$SERVICE_NAME"; then
  353. err "service failed to start; diagnostics:"
  354. $SUDO systemctl status "$SERVICE_NAME" --no-pager || true
  355. $SUDO journalctl -u "$SERVICE_NAME" -n 50 --no-pager || true
  356. exit 40
  357. fi
  358. ok "service $SERVICE_NAME active"
  359. if command -v curl >/dev/null 2>&1; then
  360. curl -fsS --max-time 5 "http://127.0.0.1:$PORT/api/health" >/dev/null 2>&1 \
  361. && ok "HTTP health check OK on :$PORT" \
  362. || warn "service is up but http://127.0.0.1:$PORT didn't answer yet (give it a few seconds)"
  363. fi
  364. fi
  365. # ------------------------------------------------------------------ summary --
  366. printf '\n%s================ %s installed ================%s\n' "$C_G" "$APP_NAME" "$C_0"
  367. printf 'Version: %s%s\n' "$NETPULSE_VERSION" "$( [ "$UPGRADING" -eq 1 ] && echo " (upgrade — previous binary at $INSTALL_DIR/$BIN_NAME.bak)" || true)"
  368. printf 'Binary: %s\n' "$INSTALL_DIR/$BIN_NAME"
  369. printf 'Data: %s (SQLite, .env, SSH keypair)\n' "$STATE_DIR"
  370. printf 'Access: http://<this-machine-ip>:%s\n' "$PORT"
  371. if [ "${FRESH_CREDENTIALS:-0}" -eq 1 ] && [ "$DRY_RUN" -eq 0 ]; then
  372. printf '\nInitial credentials (shown ONCE — change them after logging in):\n'
  373. printf ' user: admin\n password: %s\n' "$ADMIN_PASS"
  374. fi
  375. printf '\nUseful commands:\n'
  376. printf ' systemctl status %s\n journalctl -u %s -f\n' "$SERVICE_NAME" "$SERVICE_NAME"
  377. printf ' sh install.sh # update to the latest stable version\n'
  378. printf ' sh install.sh --uninstall\n'
  379. printf '\nNotes:\n'
  380. if [ "${DEMO:-0}" = "1" ]; then
  381. printf ' - DEMO MODE: sample network with 60+ devices; your routers are untouched.\n'
  382. printf ' To go live: set DEMO_MODE=0 in %s/.env and systemctl restart %s\n' "$STATE_DIR" "$SERVICE_NAME"
  383. else
  384. printf ' - To explore with sample data first: set DEMO_MODE=1 in %s/.env\n' "$STATE_DIR"
  385. printf ' and systemctl restart %s (demo mode never touches your routers).\n' "$SERVICE_NAME"
  386. fi
  387. printf ' - No firewall port was opened. If you need one:\n'
  388. printf ' firewall-cmd --permanent --add-port=%s/tcp && firewall-cmd --reload\n' "$PORT"
  389. printf ' ufw allow %s/tcp\n' "$PORT"
  390. printf ' - Live mode: authorize the server SSH public key on each router\n'
  391. printf ' (Settings shows it; append to /etc/dropbear/authorized_keys).\n'
  392. printf ' - The in-app updater follows rolling builds from main; for stable\n'
  393. printf ' updates re-run this script.\n'
  394. printf '%s================================================%s\n\n' "$C_G" "$C_0"