fix(deploy): patch existing dietpi.txt instead of overwriting #13

Merged
addison merged 2 commits from exe-dev-bot/kiosk:fix/dietpi-config-patch into main 2026-02-13 05:00:08 -05:00
Contributor

Problem

The deploy tool was overwriting the entire dietpi.txt with a minimal 34-line template. DietPi ships a 358-line config that the system scrapes for many required settings. With our minimal replacement, first-boot setup failed to install Chromium properly, causing xinit to fall back to xterm (which also wasn't installed), resulting in:

xinit: Unable to run program "xterm": No such file or directory
xinit: connection to X server lost

Fix

  • Patch instead of replace: Read the existing dietpi.txt from the flashed image, inject/replace only the settings we need, and write it back. This preserves all DietPi defaults.
  • Remove dietpi.txt.tmpl: No longer needed since we patch the existing file.
  • Fix AUTO_SETUP_CUSTOM_SCRIPT_EXEC: Was set to 1 (download from URL) but should be 0 (use local /boot/Automation_Custom_Script.sh).
  • Add AUTO_SETUP_NET_ETHERNET_ENABLED=0: Explicitly disable Ethernet when using WiFi.

How it works

PatchDietPiConfig() scans each line of the existing config:

  • If a line matches a managed key (even if commented out), it replaces the line with the desired value
  • If a managed key isn't found anywhere, it appends it at the end
  • All unmanaged settings are left untouched
## Problem The deploy tool was overwriting the entire `dietpi.txt` with a minimal 34-line template. DietPi ships a 358-line config that the system scrapes for many required settings. With our minimal replacement, first-boot setup failed to install Chromium properly, causing `xinit` to fall back to `xterm` (which also wasn't installed), resulting in: ``` xinit: Unable to run program "xterm": No such file or directory xinit: connection to X server lost ``` ## Fix - **Patch instead of replace**: Read the existing `dietpi.txt` from the flashed image, inject/replace only the settings we need, and write it back. This preserves all DietPi defaults. - **Remove `dietpi.txt.tmpl`**: No longer needed since we patch the existing file. - **Fix `AUTO_SETUP_CUSTOM_SCRIPT_EXEC`**: Was set to `1` (download from URL) but should be `0` (use local `/boot/Automation_Custom_Script.sh`). - **Add `AUTO_SETUP_NET_ETHERNET_ENABLED=0`**: Explicitly disable Ethernet when using WiFi. ## How it works `PatchDietPiConfig()` scans each line of the existing config: - If a line matches a managed key (even if commented out), it replaces the line with the desired value - If a managed key isn't found anywhere, it appends it at the end - All unmanaged settings are left untouched
Instead of overwriting the entire dietpi.txt with a minimal 34-line
template, patch the existing file from the DietPi image. This preserves
all default DietPi settings while injecting only the kiosk-specific
values we need.

Add PatchDietPiConfig() that uses line scanning to find existing keys
(including commented-out lines) and replaces them in place. Keys not
found in the existing file are appended at the end.

Remove RenderDietPiConfig and dietpi.txt.tmpl since they are no longer
needed.

Settings injected:
- AUTO_SETUP_AUTOMATED=1
- AUTO_SETUP_NET_ETHERNET_ENABLED=0 (explicit disable)
- AUTO_SETUP_NET_WIFI_ENABLED=1
- AUTO_SETUP_INSTALL_SOFTWARE_ID=113 (Chromium)
- AUTO_SETUP_AUTOSTART_TARGET_INDEX=11 (kiosk mode)
- AUTO_SETUP_CUSTOM_SCRIPT_EXEC=0
- Plus locale, timezone, password, hostname, update settings

Co-authored-by: Shelley <shelley@exe.dev>
Instead of rendering a template and writing it, read the existing
dietpi.txt from the boot partition and pass it through
PatchDietPiConfig before writing back. This ensures the full
DietPi default configuration is preserved.

Co-authored-by: Shelley <shelley@exe.dev>
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
kwila/kiosk!13
No description provided.