This file tracks the architecture changes, thinking process, and code refactors made to the ConnectBox system.
Goal: Deconstruct the monolithic PxUSBm.py script into single-responsibility, event-driven scripts.
Changes Made:
- Created
first-boot-expand.pyto handle initial filesystem expansion, triggered by a one-shotsystemdservice (first-boot-expand.service). - Created
usb_mounter.pytriggered natively byudevrules (99-usb-automount.rules) to handle USB insertion events instead of using a constant polling loop. - Created
network-watchdog.pyas a lightweight daemon to handle Wi-Fi recovery (unloading/loading kernel drivers dynamically viarmmod/modprobe) and restartinghostapd. - Relied on
systemdRestart=alwaysoverrides for process management instead of Python-based checks.
Goal: Eliminate dual-source-of-truth syncing between brand.txt and brand.j2. Move all remaining system components to read directly from the JSON-based brand.j2 file.
Changes Made:
- Updated
globals.pyto exclusively read and load configuration from/usr/local/connectbox/brand.j2instead ofbrand.txt. - Cleaned up obsolete synchronization code in
globals.py, completely removing any reads or writes to/usr/local/connectbox/brand.txt. - Updated
BrandCreationTool.pyto output configurations directly tobrand.j2. - Modified
buttons.py,usb.py,hats.py, andmmiLoader.pyto correctly reflect the updatedbrand.j2references, eliminating confusing/outdated comments referencingbrand.txt. - Removed the
sync_brand()logic entirely fromnetwork-watchdog.py. - Moving forward, the source of truth for device branding and specific flag configurations like
usb0NoMountwill exclusively bebrand.j2.