Remove deprecated one-shot scripts and update first-boot configuration for improved provisioning</message>

<message>Delete obsolete one-shot scripts for setting screen rotation and wallpaper, as well as related Python and shell scripts. Update the first-boot configuration to streamline the provisioning process by removing references to these scripts. This cleanup enhances maintainability and focuses on the essential steps required for the first boot experience, ensuring a more efficient setup for users.
This commit is contained in:
nearxos
2026-02-23 16:15:47 +02:00
parent 2d6e5aa009
commit 25bf710c67
51 changed files with 650 additions and 1192 deletions

View File

@@ -0,0 +1,12 @@
#!/bin/bash
# Step 01: Set hostname and /etc/hosts
step_01_hostname() {
echo "$HOSTNAME" > /etc/hostname
hostnamectl set-hostname "$HOSTNAME" 2>/dev/null || true
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"
}

View File

@@ -0,0 +1,10 @@
#!/bin/bash
# Step 02: Install packages
step_02_packages() {
log "Running apt-get update ..."
apt-get update -qq
log "Installing: $PACKAGES"
apt-get install -y -qq $PACKAGES
log "Packages installed"
}

View File

@@ -0,0 +1,19 @@
#!/bin/bash
# Step 03: Install reTerminal DM drivers (Seeed device-tree overlays)
step_03_reterminal_drivers() {
if [[ -z "$RETERMINAL_REPO_URL" ]]; then
log "Skipping reTerminal drivers (RETERMINAL_REPO_URL not set)"
return 0
fi
local repo="/tmp/seeed-linux-dtoverlays"
log "Cloning seeed-linux-dtoverlays ..."
git clone --depth 1 "$RETERMINAL_REPO_URL" "$repo"
log "Running reTerminal.sh --device $RETERMINAL_DEVICE ..."
if ( cd "$repo" && "$repo/scripts/reTerminal.sh" --device "$RETERMINAL_DEVICE" ); then
log "reTerminal DM drivers installed (reboot will apply)"
else
log "WARNING: reTerminal.sh failed; display/touch may still work"
fi
rm -rf "$repo"
}

View File

@@ -0,0 +1,36 @@
#!/bin/bash
# Step 04: Download kiosk scripts and launcher files from file server
step_04_kiosk_files() {
mkdir -p "$AUTOSTART" "$PI_HOME/Desktop" "$PI_HOME/.local/share/applications"
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 "$PI_USER:$PI_USER" "$PI_HOME/start-chromium.sh" "$AUTOSTART/chromium-kiosk.desktop"
# Desktop launcher icon
if curl -fsSL "${FILE_SERVER}/chromium-kiosk-launcher.desktop" -o /tmp/chromium-kiosk-launcher.desktop 2>/dev/null; then
sed "s|/home/pi|$PI_HOME|g" /tmp/chromium-kiosk-launcher.desktop > "$PI_HOME/Desktop/Chromium Kiosk.desktop"
sed "s|/home/pi|$PI_HOME|g" /tmp/chromium-kiosk-launcher.desktop > "$PI_HOME/.local/share/applications/chromium-kiosk-launcher.desktop"
chmod 755 "$PI_HOME/Desktop/Chromium Kiosk.desktop"
chmod 644 "$PI_HOME/.local/share/applications/chromium-kiosk-launcher.desktop"
chown "$PI_USER:$PI_USER" "$PI_HOME/Desktop/Chromium Kiosk.desktop" "$PI_HOME/.local/share/applications/chromium-kiosk-launcher.desktop"
rm -f /tmp/chromium-kiosk-launcher.desktop
log "Chromium kiosk launcher installed"
fi
# 5-tap close Chromium overlay
if curl -fsSL "${FILE_SERVER}/five-tap-close-chromium.py" -o "$PI_HOME/five-tap-close-chromium.py" 2>/dev/null; then
chmod 755 "$PI_HOME/five-tap-close-chromium.py"
if curl -fsSL "${FILE_SERVER}/five-tap-close-chromium.desktop" -o "$AUTOSTART/five-tap-close-chromium.desktop" 2>/dev/null; then
sed -i "s|/home/pi|$PI_HOME|g" "$AUTOSTART/five-tap-close-chromium.desktop"
chmod 644 "$AUTOSTART/five-tap-close-chromium.desktop"
chown "$PI_USER:$PI_USER" "$PI_HOME/five-tap-close-chromium.py" "$AUTOSTART/five-tap-close-chromium.desktop"
log "5-tap close Chromium installed"
fi
fi
log "Kiosk files installed"
}

View File

@@ -0,0 +1,63 @@
#!/bin/bash
# Step 05: Boot splash (Plymouth) and desktop wallpaper
step_05_splash_wallpaper() {
mkdir -p "$PLYMOUTH_DIR" /usr/share/rpd-wallpaper
if ! curl -fsSL "${FILE_SERVER}/splash.png" -o "$PLYMOUTH_DIR/splash.png"; then
log "WARNING: Could not download splash.png"; return 0
fi
cp "$PLYMOUTH_DIR/splash.png" "$WALLPAPER_PATH"
chmod 644 "$PLYMOUTH_DIR/splash.png" "$WALLPAPER_PATH"
# Plymouth theme
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"
log "Plymouth theme installed"
fi
grep -q '^Theme=custom' /etc/plymouth/plymouthd.conf 2>/dev/null \
|| printf '%s\n' '[Daemon]' 'Theme=custom' >> /etc/plymouth/plymouthd.conf
log "Running update-initramfs ..."
update-initramfs -u -k all 2>/dev/null || true
# LightDM wallpaper
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 || true
# Desktop wallpaper (pcmanfm)
for PROFILE in LXDE-pi default; do
local conf="$PI_HOME/.config/pcmanfm/$PROFILE/desktop-items-0.conf"
mkdir -p "$(dirname "$conf")"
if [[ ! -f "$conf" ]]; then
printf '%s\n' '[*]' "wallpaper=$WALLPAPER_PATH" "wallpaper_mode=$WALLPAPER_MODE" 'wallpaper_common=1' 'show_trash=0' > "$conf"
else
grep -q '^wallpaper=' "$conf" && sed -i "s|^wallpaper=.*|wallpaper=$WALLPAPER_PATH|" "$conf" || echo "wallpaper=$WALLPAPER_PATH" >> "$conf"
grep -q '^wallpaper_mode=' "$conf" && sed -i "s/^wallpaper_mode=.*/wallpaper_mode=$WALLPAPER_MODE/" "$conf" || echo "wallpaper_mode=$WALLPAPER_MODE" >> "$conf"
grep -q '^show_trash=' "$conf" && sed -i 's/^show_trash=.*/show_trash=0/' "$conf" || echo 'show_trash=0' >> "$conf"
fi
chown -R "$PI_USER:$PI_USER" "$(dirname "$conf")"
done
# Taskbar start-here icon
if curl -fsSL "${FILE_SERVER}/start-here.png" -o /tmp/start-here.png 2>/dev/null; then
local icons="/usr/share/icons/PiXtrix"
if [[ -d "$icons/32x32/places" ]]; then
for s in 16 24 32 48 64 96; do
local dest="$icons/${s}x${s}/places/start-here.png"
[[ -d "$(dirname "$dest")" ]] || continue
rm -f "$dest"
if command -v convert >/dev/null 2>&1; then
convert /tmp/start-here.png -resize "${s}x${s}" "$dest" 2>/dev/null || cp /tmp/start-here.png "$dest"
else
cp /tmp/start-here.png "$dest"
fi
chmod 644 "$dest"
done
log "Taskbar start-here icon installed"
fi
rm -f /tmp/start-here.png
fi
log "Splash and wallpaper configured"
}

View File

@@ -0,0 +1,39 @@
#!/bin/bash
# Step 06: LightDM session config + DSI panel wait service
step_06_lightdm() {
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 || true
if [[ -f /etc/lightdm/lightdm.conf ]]; then
sed -i "s/^user-session=.*/user-session=$LIGHTDM_SESSION/" /etc/lightdm/lightdm.conf
sed -i "s/^autologin-session=.*/autologin-session=$LIGHTDM_SESSION/" /etc/lightdm/lightdm.conf
log "LightDM session set to $LIGHTDM_SESSION"
fi
# Wait for DSI panel to report "connected" before LightDM starts (max 30s)
mkdir -p /etc/systemd/system/lightdm.service.d
cat > /etc/systemd/system/cm4-await-display.service << 'AWAITSVC'
[Unit]
Description=Wait for reTerminal DM DSI panel before LightDM
Before=lightdm.service
DefaultDependencies=no
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/sh -c 'echo "Waiting for DSI panel..."; for i in $(seq 1 30); do for f in /sys/class/drm/card*-DSI-1/status; do [ -f "$f" ] && [ "$(cat "$f" 2>/dev/null)" = "connected" ] && echo "DSI connected." && exit 0; done; sleep 1; done; echo "DSI timeout (30s), starting anyway."'
TimeoutStartSec=35
[Install]
WantedBy=graphical.target
AWAITSVC
printf '%s\n' '[Unit]' 'After=cm4-await-display.service' \
> /etc/systemd/system/lightdm.service.d/99-await-display.conf
systemctl daemon-reload
systemctl enable cm4-await-display.service 2>/dev/null || true
log "cm4-await-display.service installed (wait for DSI, max 30s)"
}

View File

@@ -0,0 +1,10 @@
#!/bin/bash
# Step 07: Maliit on-screen keyboard autostart
step_07_maliit() {
mkdir -p "$AUTOSTART"
curl -fsSL "${FILE_SERVER}/maliit-keyboard.desktop" \
-o "$AUTOSTART/maliit-keyboard.desktop" 2>/dev/null \
&& log "maliit-keyboard.desktop installed" \
|| log "WARNING: Could not download maliit-keyboard.desktop"
}

View File

@@ -0,0 +1,48 @@
#!/bin/bash
# Step 08: Dark theme (GTK3 settings, GTK CSS, taskbar theme)
step_08_dark_theme() {
local theme_name="$GTK_THEME_NAME"
[[ ! -d "/usr/share/themes/$theme_name" ]] && [[ -d /usr/share/themes/Adwaita-dark ]] \
&& theme_name="Adwaita-dark" && log "Using Adwaita-dark (PiXnoir not found)"
local icon_theme=""
[[ -d /usr/share/icons/PiXtrix ]] && icon_theme="PiXtrix"
# GTK3 settings
local gtk_ini="$PI_HOME/.config/gtk-3.0/settings.ini"
mkdir -p "$(dirname "$gtk_ini")"
if [[ ! -f "$gtk_ini" ]]; then
{ printf '%s\n' '[Settings]' 'gtk-application-prefer-dark-theme=1' "gtk-theme-name=$theme_name"
[[ -n "$icon_theme" ]] && echo "gtk-icon-theme-name=$icon_theme"
} > "$gtk_ini"
else
_set_ini() { grep -q "^$1=" "$gtk_ini" && sed -i "s/^$1=.*/$1=$2/" "$gtk_ini" || echo "$1=$2" >> "$gtk_ini"; }
_set_ini gtk-application-prefer-dark-theme 1
_set_ini gtk-theme-name "$theme_name"
[[ -n "$icon_theme" ]] && _set_ini gtk-icon-theme-name "$icon_theme"
fi
log "GTK theme: $theme_name" && [[ -n "$icon_theme" ]] && log "Icon theme: $icon_theme"
# GTK4/Libadwaita dark preference
if [[ -f "$PI_HOME/.profile" ]] && ! grep -q 'ADW_DEBUG_COLOR_SCHEME' "$PI_HOME/.profile" 2>/dev/null; then
printf '\n%s\n' 'export ADW_DEBUG_COLOR_SCHEME=prefer-dark' >> "$PI_HOME/.profile"
chown "$PI_USER:$PI_USER" "$PI_HOME/.profile"
log "Added prefer-dark to .profile"
fi
# Custom GTK CSS (dark menus/popovers)
curl -fsSL "${FILE_SERVER}/gtk.css" -o "$PI_HOME/.config/gtk-3.0/gtk.css" 2>/dev/null \
&& log "gtk.css installed" || true
# Taskbar theme
local panel_dir="$PI_HOME/.config/wf-panel-pi"
mkdir -p "$panel_dir"
if curl -fsSL "${FILE_SERVER}/wf-panel-pi.ini" -o "$panel_dir/wf-panel-pi.ini" 2>/dev/null; then
sed -i "s|/home/pi|$PI_HOME|g" "$panel_dir/wf-panel-pi.ini"
curl -fsSL "${FILE_SERVER}/panel-theme.css" -o "$panel_dir/panel-theme.css" 2>/dev/null || true
log "Taskbar theme installed"
fi
chown -R "$PI_USER:$PI_USER" "$PI_HOME/.config"
}

View File

@@ -0,0 +1,20 @@
#!/bin/bash
# Step 09: Re-apply Plymouth splash theme after driver install
step_09_reapply_splash() {
local cfg="/boot/firmware/config.txt"
[[ -f "$cfg" ]] || cfg="/boot/config.txt"
if [[ -f "$cfg" ]] && grep -q '^disable_splash=1' "$cfg"; then
sed -i 's/^disable_splash=1$/disable_splash=0/' "$cfg"
log "Set disable_splash=0"
fi
if [[ -f /etc/plymouth/plymouthd.conf ]]; then
sed -i '/^Theme=/d; /^\[Daemon\]$/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
fi
log "Running update-initramfs ..."
update-initramfs -u -k all 2>/dev/null || true
}

View File

@@ -0,0 +1,17 @@
#!/bin/bash
# Step 10: Kernel command line (swiotlb + DSI rotation)
step_10_cmdline() {
local cmdline="/boot/firmware/cmdline.txt"
[[ -f "$cmdline" ]] || cmdline="/boot/cmdline.txt"
[[ -f "$cmdline" ]] || { log "WARNING: cmdline.txt not found"; return 0; }
if [[ -n "$SWIOTLB_SIZE" ]] && ! grep -q 'swiotlb=' "$cmdline"; then
sed -i "s/rootwait/rootwait swiotlb=$SWIOTLB_SIZE/" "$cmdline"
log "Added swiotlb=$SWIOTLB_SIZE to cmdline"
fi
if [[ -n "$DSI_ROTATE" ]] && ! grep -q 'video=DSI-1:rotate=' "$cmdline"; then
sed -i "s/\$/ video=DSI-1:rotate=$DSI_ROTATE/" "$cmdline"
log "Added video=DSI-1:rotate=$DSI_ROTATE to cmdline"
fi
}

View File

@@ -0,0 +1,28 @@
#!/bin/bash
# Step 11: Install one-shot and per-login scripts
step_11_oneshots() {
# Rotation: install set-rotation-at-login (re-applies kanshi config every login)
if [[ -n "$DSI_ROTATE" ]]; then
log "Rotation $DSI_ROTATE set via cmdline"
if curl -fsSL "${FILE_SERVER}/set-rotation-at-login.sh" -o "$PI_HOME/set-rotation-at-login.sh" 2>/dev/null; then
chmod 755 "$PI_HOME/set-rotation-at-login.sh"
chown "$PI_USER:$PI_USER" "$PI_HOME/set-rotation-at-login.sh"
if curl -fsSL "${FILE_SERVER}/set-rotation-at-login.desktop" -o /tmp/sral.desktop 2>/dev/null; then
sed "s|/home/pi|$PI_HOME|g" /tmp/sral.desktop > "$AUTOSTART/set-rotation-at-login.desktop"
chown "$PI_USER:$PI_USER" "$AUTOSTART/set-rotation-at-login.desktop"
rm -f /tmp/sral.desktop
log "set-rotation-at-login installed"
fi
fi
fi
# Additional one-shots from config
if [[ -n "$ONESHOT_SCRIPTS" ]]; then
for _name in $ONESHOT_SCRIPTS; do
install_oneshot "$_name" || true
done
else
log "No additional one-shot scripts"
fi
}

View File

@@ -0,0 +1,7 @@
#!/bin/bash
# Step 12: Make log file appendable by the pi user
step_12_log_permissions() {
chmod 666 "$LOGFILE"
log "Log $LOGFILE now appendable by $PI_USER"
}

View File

@@ -0,0 +1,11 @@
#!/bin/bash
# Step 13: Report completion and reboot
step_13_reboot() {
local ip
ip="$(hostname -I 2>/dev/null | awk '{print $1}')"
report_status "done" "First-boot complete" "13" "reboot" "$ip"
log "Device IP: ${ip:-unknown}"
log "=== first-boot.sh finished, rebooting ==="
reboot
}