Files
firmware/payload/init.d/S60web
T
Oleksandr Shyshatskyi 4415905fb3 Initial commit: USB-installable custom firmware builder for Creator 5
Builds a modified FlashForge update package that the printer installs by
itself from a USB stick, reusing FlashForge's own updater rather than a
parallel one.

Integration is a single file: /usr/prog/PROGRAM/software/firmwareExe is
replaced with a shell script. Everything funnels through that binary, so
app_startup.sh, rcS and the init chain stay completely stock. The genuine
binary is kept as firmwareExe.stock and remains the default UI.

Key findings from the stock firmware, each enforced by a test:
- components named *.tar.xz are PLAIN tar; the installer runs bare `tar -xvf`
- the .tgz is DES3-encrypted plain tar, not gzip
- nothing in init starts Klipper -- firmwareExe runs start.sh, so replacing
  the UI without S70klipper leaves a printer that cannot move
- the installer wipes the software dir before run.sh, so an uninstall package
  must ship the genuine firmwareExe rather than back one up
- ssh already works: stock ships dropbear + an enabled S50dropbear, only the
  root password is missing

Brick-safety is designed in, not bolted on: a five-rung profile ladder
starting with a probe that changes nothing, a container-based simulation that
actually runs the installer and asserts the printer would still boot, an
uninstall round-trip test, and a SAFE-MODE latch for UI crash loops.

75 checks pass. Not yet run on hardware.
2026-08-22 21:48:56 +03:00

37 lines
1.3 KiB
Bash

#!/bin/sh
# nginx (Mainsail) + moonraker.
#
# Both binaries already ship on stock firmware -- FlashForge simply comments
# them out of /usr/prog/klipper/start.sh. We run nginx on our OWN prefix so
# their config is never modified and MOD_WEB=0 restores stock behaviour.
MODDIR=/usr/data/mod
[ -f $MODDIR/mod.conf ] && . $MODDIR/mod.conf
NGINX=/usr/prog/nginx/sbin/nginx
NGX_PID=$MODDIR/nginx/logs/nginx.pid
start() {
[ "${MOD_WEB:-1}" = "1" ] || { echo "web: disabled in mod.conf"; return 0; }
if [ -x "$NGINX" ] && [ -f $MODDIR/nginx/nginx.conf ]; then
mkdir -p $MODDIR/nginx/logs $MODDIR/nginx/tmp
$NGINX -p $MODDIR/nginx -c $MODDIR/nginx/nginx.conf \
&& echo "nginx: started" || echo "nginx: FAILED"
else
echo "nginx: not available"
fi
if [ -x /usr/prog/klipper/moonrakerDaemon ]; then
/usr/prog/klipper/moonrakerDaemon start && echo "moonraker: started"
fi
}
stop() {
[ -f "$NGX_PID" ] && kill `cat $NGX_PID` 2>/dev/null
[ -x /usr/prog/klipper/moonrakerDaemon ] && /usr/prog/klipper/moonrakerDaemon stop
echo "web: stopped"
}
case "$1" in
start|'') start ;;
stop) stop ;;
restart) stop; sleep 2; start ;;
status) [ -f "$NGX_PID" ] && echo "nginx: running" || echo "nginx: not running" ;;
*) echo "usage: $0 {start|stop|restart|status}"; exit 1 ;;
esac