From 5372fcbb81966a077fcf904fef02b47bbabb2758 Mon Sep 17 00:00:00 2001 From: nearxos Date: Fri, 20 Feb 2026 11:05:33 +0200 Subject: [PATCH] Update first-boot.sh to set hostname and configure /etc/hosts for improved system identification; add fix-reterminal-display.sh for post-boot adjustments to splash screen and Plymouth theme; modify meta-data for instance identification; update app.py to reflect new local hostname. --- .../cloud-init/first-boot.sh | 32 +++++++++++++++++ .../cloud-init/fix-reterminal-display.sh | 36 +++++++++++++++++++ .../emmc-provisioning/cloud-init/meta-data | 4 +-- .../emmc-provisioning/dashboard/app.py | 2 +- 4 files changed, 71 insertions(+), 3 deletions(-) create mode 100644 chromium-setup/emmc-provisioning/cloud-init/fix-reterminal-display.sh diff --git a/chromium-setup/emmc-provisioning/cloud-init/first-boot.sh b/chromium-setup/emmc-provisioning/cloud-init/first-boot.sh index 9530631..6d56f2d 100644 --- a/chromium-setup/emmc-provisioning/cloud-init/first-boot.sh +++ b/chromium-setup/emmc-provisioning/cloud-init/first-boot.sh @@ -8,6 +8,7 @@ export DEBIAN_FRONTEND=noninteractive # --- Constants --- # All first-boot assets live in portal-files/first-boot/ on the file server. FILE_SERVER="http://10.130.60.141:5000/files/first-boot" +HOSTNAME="gnss.guard" PI_USER="pi" PI_HOME="/home/$PI_USER" AUTOSTART="$PI_HOME/.config/autostart" @@ -21,6 +22,17 @@ exec > >(tee -a "$LOGFILE") 2>&1 log "=== first-boot.sh started ===" log "FILE_SERVER=$FILE_SERVER PI_USER=$PI_USER LOGFILE=$LOGFILE" +# --- 0. Hostname and /etc/hosts (avoids "unable to resolve host" with sudo) --- +log "--- Hostname: $HOSTNAME ---" +echo "$HOSTNAME" > /etc/hostname +hostnamectl set-hostname "$HOSTNAME" 2>/dev/null || true +# Ensure hostname resolves so sudo and other tools don't warn +if ! grep -q "127.0.1.1[[:space:]]*$HOSTNAME" /etc/hosts 2>/dev/null; then + sed -i "/127.0.1.1[[:space:]].*$/d" /etc/hosts + echo "127.0.1.1 $HOSTNAME" >> /etc/hosts +fi +log "Hostname set to $HOSTNAME; /etc/hosts updated" + # --- Helpers --- # Download script + .desktop from FILE_SERVER and install as one-shot autostart (runs once at pi's first login, then deletes itself). install_oneshot() { @@ -120,6 +132,26 @@ fi log "Removing $REPO_DIR" rm -rf "$REPO_DIR" +# --- 6b. Re-apply splash and display (Seeed script sets disable_splash=1 and can duplicate Plymouth theme) --- +log "--- Re-applying boot splash and Plymouth theme ---" +CFG_PATH="/boot/firmware/config.txt" +[[ -f /boot/firmware/config.txt ]] || CFG_PATH="/boot/config.txt" +if [[ -f "$CFG_PATH" ]]; then + if grep -q '^disable_splash=1' "$CFG_PATH"; then + sed -i 's/^disable_splash=1$/disable_splash=0/' "$CFG_PATH" + log "Set disable_splash=0 so Plymouth splash is shown" + fi +fi +# Ensure Plymouth uses our custom theme only (remove Theme=pix, set Theme=custom) +if [[ -f /etc/plymouth/plymouthd.conf ]]; then + sed -i '/^Theme=/d' /etc/plymouth/plymouthd.conf + grep -q '^\[Daemon\]' /etc/plymouth/plymouthd.conf || echo '[Daemon]' >> /etc/plymouth/plymouthd.conf + echo 'Theme=custom' >> /etc/plymouth/plymouthd.conf + log "Plymouth theme set to custom only" +fi +log "Running update-initramfs to apply Plymouth theme ..." +update-initramfs -u -k all 2>/dev/null || true + # --- 7. One-shots (rotation + wallpaper at first login) --- log "--- One-shot scripts (run at pi first login) ---" install_oneshot set-rotation-once || true diff --git a/chromium-setup/emmc-provisioning/cloud-init/fix-reterminal-display.sh b/chromium-setup/emmc-provisioning/cloud-init/fix-reterminal-display.sh new file mode 100644 index 0000000..ecc9ffa --- /dev/null +++ b/chromium-setup/emmc-provisioning/cloud-init/fix-reterminal-display.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# One-time fix for reTerminal DM after first-boot: splash, Plymouth theme, rotation, wallpaper. +# Run on the device as root (e.g. sudo bash fix-reterminal-display.sh). +# Or run over SSH: ssh pi@DEVICE_IP 'sudo bash -s' < fix-reterminal-display.sh + +set -e +PI_USER="${PI_USER:-pi}" +PI_HOME="/home/$PI_USER" +CFG_PATH="/boot/firmware/config.txt" +[[ -f "$CFG_PATH" ]] || CFG_PATH="/boot/config.txt" + +echo "=== Fixing boot splash (disable_splash=0) ===" +if [[ -f "$CFG_PATH" ]]; then + sed -i 's/^disable_splash=1$/disable_splash=0/' "$CFG_PATH" || true + grep -q '^disable_splash=' "$CFG_PATH" || echo 'disable_splash=0' >> "$CFG_PATH" + echo "Done. config: $(grep disable_splash "$CFG_PATH")" +fi + +echo "=== Fixing Plymouth theme (custom only) ===" +if [[ -f /etc/plymouth/plymouthd.conf ]]; then + sed -i '/^Theme=/d' /etc/plymouth/plymouthd.conf + grep -q '^\[Daemon\]' /etc/plymouth/plymouthd.conf || echo '[Daemon]' >> /etc/plymouth/plymouthd.conf + echo 'Theme=custom' >> /etc/plymouth/plymouthd.conf + echo "Done. plymouthd.conf Theme: $(grep Theme= /etc/plymouth/plymouthd.conf)" +fi +update-initramfs -u -k all 2>/dev/null || true + +echo "=== Rotation and wallpaper (run as $PI_USER at next login or now via sudo -u) ===" +echo "To set rotation and wallpaper now (with X running), run as $PI_USER:" +echo " export DISPLAY=:0" +echo " kscreen-doctor output.DSI-1.rotation.right" +echo " plasma-apply-wallpaperimage /usr/share/rpd-wallpaper/splash.png" +echo "" +echo "Or ensure one-shots run at next login (they are in autostart if still present)." +echo "=== Reboot to apply splash and initramfs ===" +echo " sudo reboot" diff --git a/chromium-setup/emmc-provisioning/cloud-init/meta-data b/chromium-setup/emmc-provisioning/cloud-init/meta-data index ed480ec..c2c5b86 100644 --- a/chromium-setup/emmc-provisioning/cloud-init/meta-data +++ b/chromium-setup/emmc-provisioning/cloud-init/meta-data @@ -1,5 +1,5 @@ # NoCloud meta-data: enables cloud-init. Optional instance-id for multi-device. # Copy to the boot (FAT32) partition of your image as 'meta-data'. -instance-id: reterminal-01 -# local-hostname: reterminal-01 # optional override +instance-id: gnss-guard-01 +# local-hostname: gnss.guard # optional override; first-boot.sh also sets this diff --git a/chromium-setup/emmc-provisioning/dashboard/app.py b/chromium-setup/emmc-provisioning/dashboard/app.py index 44ab230..ea2439b 100644 --- a/chromium-setup/emmc-provisioning/dashboard/app.py +++ b/chromium-setup/emmc-provisioning/dashboard/app.py @@ -165,7 +165,7 @@ runcmd: """ DEFAULT_META_DATA = """instance-id: raspios-cloudinit-001 -local-hostname: reterminal +local-hostname: gnss.guard """ DEFAULT_NETWORK_CONFIG = """version: 2