Skip to content

Dev-Tooling + Hardware-Profile — backup/restore, deploy_box, 2S3P 15Ah profile#150

Open
wowa1990 wants to merge 7 commits into
splitti:mainfrom
wowa1990:pr-dev-tooling-hardware-profile
Open

Dev-Tooling + Hardware-Profile — backup/restore, deploy_box, 2S3P 15Ah profile#150
wowa1990 wants to merge 7 commits into
splitti:mainfrom
wowa1990:pr-dev-tooling-hardware-profile

Conversation

@wowa1990

Copy link
Copy Markdown

Was es macht

  • backup_box.sh + restore_box.sh als atomic-ish Backup-Pair (inkl. www/-Theming, cover/, theme-data/ preserve→restore)
  • deploy_box.sh als Wrapper für Box-Updates (toleriert unzip-Warnings, installiert Telegram-Deps, macht restart-Sequenz)
  • Phase-1-Deployment-Wrapper für die Initial-Lockdown-Patches
  • Dev-Coverage-Script für AdminInterface PHP-Pages
  • Neues Akku-Profil ENERpower 2S3P 15.000 mAh (Samsung INR21700-50E) im mupiboxconfig.json-Template
  • Korrektur des bestehenden 2S2P-Profils (v_100 8000→8200, v_0 6000→6400) für korrektere Samsung-INR21700-Curve

Architektur (kurz)

Skripte liegen unter dev/ bzw. update/ und greifen nicht in den normalen Box-Boot ein. Akku-Profil ist eine reine Datenänderung im Config-Template — ENERpower-2S3P-Besitzer können das Profil in der Admin-UI auswählen.

Test in Codespaces / lokal

  1. Branch, Setup
  2. Konkrete Tests:
    • bash -n dev/deploy_box.sh, bash -n dev/backup_box.sh, bash -n dev/restore_box.sh → clean
    • Admin-UI „Akku-Profil" Auswahl öffnen → erwartet neuer Eintrag „ENERpower 2S3P 15.000mAh" sichtbar
    • Im 2S2P-Profil die geänderten v_100 / v_0 Werte prüfen

Hinweis: Reale Deploy-/Backup-/Restore-Läufe und das tatsächliche Verhalten des 2S3P-Profils auf Hardware sind nur auf realer Box prüfbar (verlange ENERpower-Pack + mupihat).

Offene Punkte

  • Verstehe wenn du Deploy-Scripts nicht magst — die Skripte sind dann eher als „Sample-Implementation" zu verstehen, ich bin Cherry-Pick-bereit falls du nur das Akku-Profil + 2S2P-Korrektur willst.

wowa1990 added 7 commits May 16, 2026 18:37
Pre-deploy snapshot of every file the deploy will replace plus the user-
state JSONs (resume.json, data.json, mupiboxconfig.json), written to a
timestamped /home/dietpi/mupibox-backup-<TS>/ on the SD card so a full
rollback is possible. restore_box.sh takes that path and rolls back code
+ trim scripts; user-state restore is opt-in (printed as hints, not run)
because the deploy doesn't touch those files in normal operation.

Both scripts run on the box itself; from the dev machine pipe via stdin:

  ssh dietpi@<box-ip> 'bash -s' < scripts/dev/backup_box.sh
Companion to backup_box.sh / restore_box.sh. Takes a backup directory
as input, verifies the deploy.zip is well-formed before touching live
files, restores the user-customised www/ files (active_theme.css,
cover/, theme-data/) from the backup INTO the new www/ before swapping
it in, and restarts pm2. Also installs updated trim scripts from /tmp/
if the dev machine uploaded them. Cleans its staging dir on EXIT trap.

Pre-flight: scp deploy.zip + (optionally) the trim scripts to /tmp/
on the box, then pipe this script in:

  cmd /c "ssh dietpi@<box> bash -s -- <backup-dir> < scripts\dev\deploy_box.sh"
PowerShell's Compress-Archive produces ZIPs with backslash path
separators, which unzip flags with exit code 1 ("warning, processing
continued"). With set -e that aborted the deploy before any files were
copied. Treat exit codes 0 and 1 as success; 2+ are actual failures.
The post-unzip path-existence check still runs, so a genuinely broken
extraction is caught before pm2 stops.
Companion to the multi-chat Telegram refactor. The on-box telegram
scripts and the new shared telegram_chats.py helper need to land in
/usr/local/bin/mupibox/, and mupi_telegram.service has to restart so
the receiver picks up the new ALLOWED_CHAT_IDS set and the /limit
command. Pre-flight: scp scripts/telegram/*.py to /tmp/.
backup_box.sh now copies /var/www to admin-www/ in the snapshot.
deploy_box.sh installs smart.php (and any other PHP that lands in
/tmp via scp) to /var/www, owned by dietpi:dietpi mode 644.
restore_box.sh syncs admin-www/ back to /var/www on rollback.

Discovered while deploying the multi-chat Telegram changes — smart.php
lives at /var/www/smart.php on the box, served by Apache, not part of
the Angular deploy.zip.
- scripts/dev/deploy_phase1.ps1 (NEU): one-shot Wrapper für Windows.
  Baut deploy.zip neu (frontend-box → backend-api → backend-player),
  stagt die 8 PHP-Phase-1-Dateien + 2 BT-Skripte, scp't alles nach
  /tmp/, ruft backup_box.sh + deploy_box.sh per ssh auf, druckt zum
  Schluss die fünf Verifikations-Curls. -SkipBuild und -DryRun für
  Re-Runs.

- scripts/dev/deploy_box.sh: zwei neue Install-Blöcke. Wenn
  /tmp/admin_phase1/ existiert, werden admin.php / backup.php /
  fullbackup.php / debug.php / pm2logs.php / support_data.php /
  backend.php / jsoneditor.php nach /var/www/ und includes/header.php
  nach /var/www/includes/ installiert (allowlisted, kein wildcard rm).
  Wenn /tmp/pair_bt.sh oder /tmp/remove_bt.sh existieren, gehen die
  nach /usr/local/bin/mupibox/ (Mode 755, root:root).
New battery profile entry for the ENERpower 2S3P 15.000mAh pack (Samsung
INR21700-50E cells, 3P × 5000 mAh, charge end 8.4V, BMS cutoff 6V):

  v_100=8200  v_75=7700  v_50=7400  v_25=7000  v_0=6400
  th_warning=6700  th_shutdown=6500

The 2P/3P distinction does not affect pack voltage — only capacity — so
the curve mirrors what the corrected 2S2P entry now uses.

Corrections to the existing "ENERpower 2S2P 10.000mAh" profile (Backlog
L3): the old values reported 100% at 8.0V (actual top of charge is 8.4V,
so display saturated below real full) and dropped 0% at exactly the BMS
cutoff (6.0V, where the pack has already shut down — display never
reached 0 cleanly). Same corrected curve applied.

Deployment touches three places:

  config/templates/mupiboxconfig.json
    - 2S2P entry rewritten to corrected values
    - new 2S3P entry inserted between 2S2P and USB-C

  update/conf_update.sh
    - fresh-install jq filter (only runs when selected_battery is null)
      updated to include the corrected 2S2P + new 2S3P entries
    - new idempotent backfill block (H4-pattern): if the battery_types
      array does not contain "ENERpower 2S3P 15.000mAh", append it.
      Does not touch selected_battery or any other entry — existing
      profile choices and custom values are preserved.

User still needs to select the new profile via Admin → MuPiHAT →
Battery selection after the config migration runs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant