Dev-Tooling + Hardware-Profile — backup/restore, deploy_box, 2S3P 15Ah profile#150
Open
wowa1990 wants to merge 7 commits into
Open
Dev-Tooling + Hardware-Profile — backup/restore, deploy_box, 2S3P 15Ah profile#150wowa1990 wants to merge 7 commits into
wowa1990 wants to merge 7 commits into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Was es macht
backup_box.sh+restore_box.shals atomic-ish Backup-Pair (inkl.www/-Theming,cover/,theme-data/preserve→restore)deploy_box.shals Wrapper für Box-Updates (toleriert unzip-Warnings, installiert Telegram-Deps, macht restart-Sequenz)mupiboxconfig.json-Templatev_100 8000→8200,v_0 6000→6400) für korrektere Samsung-INR21700-CurveArchitektur (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
bash -n dev/deploy_box.sh,bash -n dev/backup_box.sh,bash -n dev/restore_box.sh→ cleanHinweis: 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