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.
This commit is contained in:
@@ -8,6 +8,7 @@ export DEBIAN_FRONTEND=noninteractive
|
|||||||
# --- Constants ---
|
# --- Constants ---
|
||||||
# All first-boot assets live in portal-files/first-boot/ on the file server.
|
# 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"
|
FILE_SERVER="http://10.130.60.141:5000/files/first-boot"
|
||||||
|
HOSTNAME="gnss.guard"
|
||||||
PI_USER="pi"
|
PI_USER="pi"
|
||||||
PI_HOME="/home/$PI_USER"
|
PI_HOME="/home/$PI_USER"
|
||||||
AUTOSTART="$PI_HOME/.config/autostart"
|
AUTOSTART="$PI_HOME/.config/autostart"
|
||||||
@@ -21,6 +22,17 @@ exec > >(tee -a "$LOGFILE") 2>&1
|
|||||||
log "=== first-boot.sh started ==="
|
log "=== first-boot.sh started ==="
|
||||||
log "FILE_SERVER=$FILE_SERVER PI_USER=$PI_USER LOGFILE=$LOGFILE"
|
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 ---
|
# --- Helpers ---
|
||||||
# Download script + .desktop from FILE_SERVER and install as one-shot autostart (runs once at pi's first login, then deletes itself).
|
# Download script + .desktop from FILE_SERVER and install as one-shot autostart (runs once at pi's first login, then deletes itself).
|
||||||
install_oneshot() {
|
install_oneshot() {
|
||||||
@@ -120,6 +132,26 @@ fi
|
|||||||
log "Removing $REPO_DIR"
|
log "Removing $REPO_DIR"
|
||||||
rm -rf "$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) ---
|
# --- 7. One-shots (rotation + wallpaper at first login) ---
|
||||||
log "--- One-shot scripts (run at pi first login) ---"
|
log "--- One-shot scripts (run at pi first login) ---"
|
||||||
install_oneshot set-rotation-once || true
|
install_oneshot set-rotation-once || true
|
||||||
|
|||||||
@@ -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"
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
# NoCloud meta-data: enables cloud-init. Optional instance-id for multi-device.
|
# NoCloud meta-data: enables cloud-init. Optional instance-id for multi-device.
|
||||||
# Copy to the boot (FAT32) partition of your image as 'meta-data'.
|
# Copy to the boot (FAT32) partition of your image as 'meta-data'.
|
||||||
|
|
||||||
instance-id: reterminal-01
|
instance-id: gnss-guard-01
|
||||||
# local-hostname: reterminal-01 # optional override
|
# local-hostname: gnss.guard # optional override; first-boot.sh also sets this
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ runcmd:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
DEFAULT_META_DATA = """instance-id: raspios-cloudinit-001
|
DEFAULT_META_DATA = """instance-id: raspios-cloudinit-001
|
||||||
local-hostname: reterminal
|
local-hostname: gnss.guard
|
||||||
"""
|
"""
|
||||||
|
|
||||||
DEFAULT_NETWORK_CONFIG = """version: 2
|
DEFAULT_NETWORK_CONFIG = """version: 2
|
||||||
|
|||||||
Reference in New Issue
Block a user