Enhance first-boot script and documentation for eMMC provisioning: add structured logging, improve package installation process, and implement one-shot autostart for rotation and wallpaper setup. Update dashboard to manage portal file descriptions and enhance admin interface with new navigation links.
This commit is contained in:
@@ -1,81 +1,96 @@
|
||||
#!/bin/bash
|
||||
# First-boot script: install packages, Chromium kiosk, KDE Plasma + touch.
|
||||
# Intended to be downloaded and run by cloud-init (see user-data-remote-gnss.example).
|
||||
# Run as root.
|
||||
# First-boot: packages, Chromium kiosk, KDE Plasma + touch, reTerminal DM drivers.
|
||||
# Run by cloud-init (user-data-remote-gnss.example). Run as root.
|
||||
|
||||
set -e
|
||||
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# Packages
|
||||
# --- 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"
|
||||
PI_USER="pi"
|
||||
PI_HOME="/home/$PI_USER"
|
||||
AUTOSTART="$PI_HOME/.config/autostart"
|
||||
LOGFILE="/var/log/first-boot.log"
|
||||
PLYMOUTH_DIR="/usr/share/plymouth/themes/custom"
|
||||
WALLPAPER_PATH="/usr/share/rpd-wallpaper/splash.png"
|
||||
|
||||
# --- Logging ---
|
||||
log() { echo "[$(date -Iseconds)] $*"; }
|
||||
exec > >(tee -a "$LOGFILE") 2>&1
|
||||
log "=== first-boot.sh started ==="
|
||||
|
||||
# --- 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() {
|
||||
local name="$1"
|
||||
log "--- Installing one-shot: $name ---"
|
||||
curl -fsSL "${FILE_SERVER}/${name}.sh" -o "$PI_HOME/${name}.sh" || { log "WARNING: Could not download ${name}.sh"; return 1; }
|
||||
curl -fsSL "${FILE_SERVER}/${name}.desktop" -o "$AUTOSTART/${name}.desktop" || { log "WARNING: Could not download ${name}.desktop"; return 1; }
|
||||
chmod 755 "$PI_HOME/${name}.sh" && chmod 644 "$AUTOSTART/${name}.desktop"
|
||||
chown "$PI_USER:$PI_USER" "$PI_HOME/${name}.sh" "$AUTOSTART/${name}.desktop"
|
||||
}
|
||||
|
||||
# --- 1. Packages ---
|
||||
log "--- Installing packages ---"
|
||||
apt-get update -qq
|
||||
apt-get install -y -qq \
|
||||
git \
|
||||
chromium-browser \
|
||||
wmctrl \
|
||||
openssh-server \
|
||||
kde-plasma-desktop \
|
||||
maliit-keyboard \
|
||||
xinput-calibrator
|
||||
apt-get install -y -qq git chromium-browser wmctrl openssh-server \
|
||||
kde-plasma-desktop kscreen maliit-keyboard xinput-calibrator
|
||||
|
||||
# Autostart dir for user pi
|
||||
mkdir -p /home/pi/.config/autostart
|
||||
# --- 2. Dirs and kiosk files from file server ---
|
||||
log "--- Kiosk files ---"
|
||||
mkdir -p "$AUTOSTART"
|
||||
curl -fsSL "${FILE_SERVER}/start-chromium.sh" -o "$PI_HOME/start-chromium.sh"
|
||||
curl -fsSL "${FILE_SERVER}/chromium-kiosk.desktop" -o "$AUTOSTART/chromium-kiosk.desktop"
|
||||
chmod 755 "$PI_HOME/start-chromium.sh" && chmod 644 "$AUTOSTART/chromium-kiosk.desktop"
|
||||
chown -R "$PI_USER:$PI_USER" "$PI_HOME/start-chromium.sh" "$AUTOSTART/chromium-kiosk.desktop"
|
||||
|
||||
# Chromium kiosk files from file server
|
||||
FILE_SERVER="http://10.130.60.141:5000/files"
|
||||
curl -fsSL "${FILE_SERVER}/start-chromium.sh" -o /home/pi/start-chromium.sh
|
||||
chmod 755 /home/pi/start-chromium.sh
|
||||
chown pi:pi /home/pi/start-chromium.sh
|
||||
curl -fsSL "${FILE_SERVER}/chromium-kiosk.desktop" -o /home/pi/.config/autostart/chromium-kiosk.desktop
|
||||
chmod 644 /home/pi/.config/autostart/chromium-kiosk.desktop
|
||||
chown pi:pi /home/pi/.config/autostart/chromium-kiosk.desktop
|
||||
# --- 3. Boot splash and wallpaper (splash.png + Plymouth theme from file server) ---
|
||||
log "--- Boot splash and wallpaper ---"
|
||||
mkdir -p "$PLYMOUTH_DIR" /usr/share/rpd-wallpaper
|
||||
if curl -fsSL "${FILE_SERVER}/splash.png" -o "$PLYMOUTH_DIR/splash.png"; then
|
||||
cp "$PLYMOUTH_DIR/splash.png" "$WALLPAPER_PATH"
|
||||
chmod 644 "$PLYMOUTH_DIR/splash.png" "$WALLPAPER_PATH"
|
||||
if curl -fsSL "${FILE_SERVER}/custom.plymouth" -o "$PLYMOUTH_DIR/custom.plymouth" \
|
||||
&& curl -fsSL "${FILE_SERVER}/custom.script" -o "$PLYMOUTH_DIR/custom.script"; then
|
||||
chmod 644 "$PLYMOUTH_DIR/custom.plymouth" "$PLYMOUTH_DIR/custom.script"
|
||||
else
|
||||
log "WARNING: Could not download custom.plymouth/custom.script; boot splash theme may be incomplete"
|
||||
fi
|
||||
grep -q '^Theme=custom' /etc/plymouth/plymouthd.conf 2>/dev/null || printf '%s\n' '[Daemon]' 'Theme=custom' >> /etc/plymouth/plymouthd.conf
|
||||
update-initramfs -u -k all 2>/dev/null || true
|
||||
mkdir -p /etc/lightdm/lightdm.conf.d
|
||||
curl -fsSL "${FILE_SERVER}/99-wallpaper.conf" -o /etc/lightdm/lightdm.conf.d/99-wallpaper.conf 2>/dev/null || log "WARNING: Could not download 99-wallpaper.conf"
|
||||
log "Splash and wallpaper set from file server"
|
||||
else
|
||||
log "WARNING: Could not download splash.png"
|
||||
fi
|
||||
|
||||
# KDE Plasma: default session (X11 for Chromium)
|
||||
# --- 4. LightDM: KDE Plasma X11 session + configs from file server ---
|
||||
log "--- LightDM session ---"
|
||||
mkdir -p /etc/lightdm/lightdm.conf.d
|
||||
cat > /etc/lightdm/lightdm.conf.d/99-default-session.conf << 'LIGHTDM'
|
||||
[Seat:*]
|
||||
user-session=plasmax11
|
||||
LIGHTDM
|
||||
curl -fsSL "${FILE_SERVER}/99-default-session.conf" -o /etc/lightdm/lightdm.conf.d/99-default-session.conf 2>/dev/null || log "WARNING: Could not download 99-default-session.conf"
|
||||
|
||||
# KDE touch-friendly
|
||||
cat > /home/pi/.config/kdeglobals << 'KDE'
|
||||
[General]
|
||||
ForceFontDPI=120
|
||||
KDE
|
||||
chown pi:pi /home/pi/.config/kdeglobals
|
||||
chmod 644 /home/pi/.config/kdeglobals
|
||||
|
||||
cat > /home/pi/.config/kwinrc << 'KWIN'
|
||||
[Windows]
|
||||
BorderlessMaximizedWindows=true
|
||||
[Plugins]
|
||||
touchpointsEnabled=true
|
||||
KWIN
|
||||
chown pi:pi /home/pi/.config/kwinrc
|
||||
chmod 644 /home/pi/.config/kwinrc
|
||||
|
||||
# On-screen keyboard (maliit)
|
||||
cat > /home/pi/.config/autostart/maliit-keyboard.desktop << 'MALIIT'
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=Maliit Keyboard
|
||||
Exec=maliit-keyboard -r
|
||||
X-GNOME-Autostart-enabled=true
|
||||
MALIIT
|
||||
chown pi:pi /home/pi/.config/autostart/maliit-keyboard.desktop
|
||||
chmod 644 /home/pi/.config/autostart/maliit-keyboard.desktop
|
||||
|
||||
# Ownership for all of pi's config
|
||||
chown -R pi:pi /home/pi/.config
|
||||
|
||||
# Set KDE Plasma (X11) as default session
|
||||
# --- 5. KDE touch-friendly + Maliit (from file server) ---
|
||||
log "--- KDE and Maliit ---"
|
||||
mkdir -p "$AUTOSTART" "$PI_HOME/.config"
|
||||
curl -fsSL "${FILE_SERVER}/kdeglobals" -o "$PI_HOME/.config/kdeglobals" 2>/dev/null || log "WARNING: Could not download kdeglobals"
|
||||
curl -fsSL "${FILE_SERVER}/kwinrc" -o "$PI_HOME/.config/kwinrc" 2>/dev/null || log "WARNING: Could not download kwinrc"
|
||||
curl -fsSL "${FILE_SERVER}/maliit-keyboard.desktop" -o "$AUTOSTART/maliit-keyboard.desktop" 2>/dev/null || log "WARNING: Could not download maliit-keyboard.desktop"
|
||||
chown -R "$PI_USER:$PI_USER" "$PI_HOME/.config"
|
||||
update-alternatives --set x-session-manager /usr/bin/startplasma-x11 2>/dev/null || true
|
||||
|
||||
# reTerminal DM: install Seeed display/touch drivers (screen will work after reboot)
|
||||
# --- 6. reTerminal DM drivers (Seeed) ---
|
||||
log "--- reTerminal DM drivers ---"
|
||||
REPO_DIR="/tmp/seeed-linux-dtoverlays"
|
||||
git clone --depth 1 https://github.com/Seeed-Studio/seeed-linux-dtoverlays "$REPO_DIR"
|
||||
"$REPO_DIR/scripts/reTerminal.sh" --device reTerminal-DM
|
||||
rm -rf "$REPO_DIR"
|
||||
|
||||
# Reboot so display and touch work
|
||||
# --- 7. One-shots (rotation + wallpaper at first login) ---
|
||||
install_oneshot set-rotation-once || true
|
||||
install_oneshot set-wallpaper-once || true
|
||||
|
||||
# --- 8. Reboot ---
|
||||
log "=== first-boot.sh finished, rebooting ==="
|
||||
reboot
|
||||
|
||||
Reference in New Issue
Block a user