97 lines
4.7 KiB
Bash
97 lines
4.7 KiB
Bash
#!/bin/bash
|
|
# 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
|
|
|
|
# --- 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 kscreen maliit-keyboard xinput-calibrator
|
|
|
|
# --- 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"
|
|
|
|
# --- 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
|
|
|
|
# --- 4. LightDM: KDE Plasma X11 session + configs from file server ---
|
|
log "--- LightDM session ---"
|
|
mkdir -p /etc/lightdm/lightdm.conf.d
|
|
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"
|
|
|
|
# --- 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
|
|
|
|
# --- 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"
|
|
|
|
# --- 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
|