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

@@ -1,19 +1,22 @@
#!/usr/bin/env bash
# Revision: 2
# Revision: 4
# Sync portal (file server) content from the repo to the LXC.
# Updates /var/lib/cm4-provisioning/portal-files/ so first-boot and the
# dashboard /files/ serve the same scripts and assets as in the repo.
#
# Files first-boot.sh downloads from FILE_SERVER (../files/first-boot/):
# Required: start-chromium.sh, chromium-kiosk.desktop, splash.png,
# custom.plymouth, custom.script, 99-wallpaper.conf,
# 99-default-session.conf, maliit-keyboard.desktop
# One-shots (if ONESHOT_SCRIPTS set): <name>.sh + <name>.desktop
# e.g. 01-set-rotation-once.sh, 01-set-rotation-once.desktop,
# 02-set-wallpaper-once.sh, 02-set-wallpaper-once.desktop
# Optional: first-boot.conf (downloaded to /tmp by cloud-init runcmd)
# Note: splash.png is not in the repo; add it to plymouth-custom/ or upload
# via the portal if you want a custom boot splash.
# All files that first-boot.sh downloads live in cloud-init/fileserver/.
# This script rsyncs that folder to the LXC's portal-files directory so
# the dashboard /files/ endpoint serves them.
#
# Expected layout on the LXC after sync:
# /var/lib/cm4-provisioning/portal-files/
# ├── first-boot.sh ← cloud-init runcmd downloads this
# ├── first-boot.conf ← cloud-init runcmd downloads this (required)
# ├── first-boot.conf.example ← reference
# └── first-boot/ ← FILE_SERVER points here
# ├── steps/
# │ ├── 01-hostname.sh … 13-reboot.sh
# ├── start-chromium.sh
# ├── splash.png
# └── ...
#
# Usage: ./sync-portal-files-to-lxc.sh [user@lxc_ip]
# Example: ./sync-portal-files-to-lxc.sh root@10.130.60.141
@@ -23,45 +26,109 @@ LXC="${1:-root@10.130.60.141}"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_DIR="$(dirname "$SCRIPT_DIR")"
CLOUDINIT_DIR="$REPO_DIR/cloud-init"
FILESERVER_DIR="$CLOUDINIT_DIR/fileserver"
REMOTE_PORTAL="/var/lib/cm4-provisioning/portal-files"
REMOTE_FIRST_BOOT="${REMOTE_PORTAL}/first-boot"
if [[ ! -d "$CLOUDINIT_DIR" ]]; then
echo "Error: cloud-init dir not found: $CLOUDINIT_DIR"
# Files we sync to the portal root (outside first-boot/)
PORTAL_ROOT_FILES=(first-boot.sh first-boot.conf first-boot.conf.example)
# ── Validate local files ────────────────────────────────────────────────
if [[ ! -d "$FILESERVER_DIR" ]]; then
echo "Error: fileserver dir not found: $FILESERVER_DIR"
exit 1
fi
if [[ ! -f "$CLOUDINIT_DIR/first-boot.sh" ]]; then
echo "Error: first-boot.sh not found in $CLOUDINIT_DIR"
exit 1
fi
if [[ ! -f "$CLOUDINIT_DIR/first-boot.conf" ]]; then
echo "Warning: first-boot.conf not found — first-boot.sh requires it!"
fi
echo "Syncing portal files to $LXC ($REMOTE_PORTAL) ..."
echo "╔══════════════════════════════════════════════════════════════╗"
echo "║ Sync portal files → $LXC"
echo "╚══════════════════════════════════════════════════════════════╝"
echo ""
# ── Ensure rsync on LXC ────────────────────────────────────────────────
ssh "$LXC" "command -v rsync >/dev/null 2>&1 || (apt-get update -qq && apt-get install -y rsync)"
ssh "$LXC" "mkdir -p $REMOTE_FIRST_BOOT"
# --- Portal root (URL /files/...) ---
# first-boot.sh: cloud-init runcmd downloads this
rsync -avz "$CLOUDINIT_DIR/first-boot.sh" "$LXC:$REMOTE_PORTAL/"
# Optional config: cloud-init can download to /tmp/first-boot.conf before running first-boot.sh
rsync -avz "$CLOUDINIT_DIR/first-boot.conf.example" "$LXC:$REMOTE_PORTAL/"
[[ -f "$CLOUDINIT_DIR/first-boot.conf" ]] && rsync -avz "$CLOUDINIT_DIR/first-boot.conf" "$LXC:$REMOTE_PORTAL/" || true
# ── Dry-run: show what will change ──────────────────────────────────────
echo "── Preview (dry-run) ──────────────────────────────────────────"
echo ""
echo "Portal root ($REMOTE_PORTAL/):"
for f in "${PORTAL_ROOT_FILES[@]}"; do
if [[ -f "$CLOUDINIT_DIR/$f" ]]; then
echo "$f"
else
echo "$f (not found locally, will skip)"
fi
done
echo ""
echo "first-boot/ assets ($REMOTE_FIRST_BOOT/):"
CHANGES=$(rsync -avzn --delete "$FILESERVER_DIR/" "$LXC:$REMOTE_FIRST_BOOT/" 2>&1 | grep -v '^\(sending\|sent\|total\|$\|building\|\.d\.\.\.\.\.\.\.\.\.\)' | head -40)
if [[ -z "$CHANGES" ]]; then
echo " (no changes)"
else
echo "$CHANGES" | sed 's/^/ /'
fi
echo ""
# --- first-boot/ (URL /files/first-boot/...) ---
# Config files: LightDM, Maliit, Chromium kiosk, one-shot .desktop files
rsync -avz --exclude='README.md' \
"$CLOUDINIT_DIR/config-files/" \
"$LXC:$REMOTE_FIRST_BOOT/"
read -rp "Proceed with sync? [Y/n] " CONFIRM
CONFIRM="${CONFIRM:-Y}"
if [[ ! "$CONFIRM" =~ ^[Yy]$ ]]; then
echo "Aborted."
exit 0
fi
# Kiosk and scripts
rsync -avz \
"$CLOUDINIT_DIR/start-chromium.sh" \
"$CLOUDINIT_DIR/five-tap-close-chromium.py" \
"$CLOUDINIT_DIR/01-set-rotation-once.sh" \
"$CLOUDINIT_DIR/02-set-wallpaper-once.sh" \
"$CLOUDINIT_DIR/set-rotation-at-login.sh" \
"$CLOUDINIT_DIR/fix-reterminal-display.sh" \
"$LXC:$REMOTE_FIRST_BOOT/"
# ── Sync portal root files ──────────────────────────────────────────────
echo ""
echo "── Syncing portal root files ──────────────────────────────────"
for f in "${PORTAL_ROOT_FILES[@]}"; do
if [[ -f "$CLOUDINIT_DIR/$f" ]]; then
rsync -avz "$CLOUDINIT_DIR/$f" "$LXC:$REMOTE_PORTAL/"
fi
done
# Plymouth theme (custom.plymouth, custom.script; add splash.png to this dir or upload via portal)
rsync -avz \
"$CLOUDINIT_DIR/files-from-guard/plymouth-custom/" \
"$LXC:$REMOTE_FIRST_BOOT/"
# ── Sync fileserver/ → first-boot/ (with --delete) ──────────────────────
echo ""
echo "── Syncing fileserver/ → first-boot/ ──────────────────────────"
rsync -avz --delete "$FILESERVER_DIR/" "$LXC:$REMOTE_FIRST_BOOT/"
# ── Check for extra files in portal root ────────────────────────────────
echo ""
echo "── Checking for extra files in portal root ────────────────────"
REMOTE_FILES=$(ssh "$LXC" "find $REMOTE_PORTAL -maxdepth 1 -not -path $REMOTE_PORTAL -printf '%f\n' 2>/dev/null" | sort)
EXPECTED_FILES=$(printf '%s\n' "${PORTAL_ROOT_FILES[@]}" "first-boot" | sort)
EXTRA_FILES=$(comm -23 <(echo "$REMOTE_FILES") <(echo "$EXPECTED_FILES"))
if [[ -z "$EXTRA_FILES" ]]; then
echo " No extra files found. Portal root is clean."
else
echo " Extra files/folders found in $REMOTE_PORTAL/:"
echo "$EXTRA_FILES" | while read -r f; do
SIZE=$(ssh "$LXC" "du -sh '$REMOTE_PORTAL/$f' 2>/dev/null | cut -f1" 2>/dev/null || echo "?")
TYPE="file"
ssh "$LXC" "[ -d '$REMOTE_PORTAL/$f' ]" 2>/dev/null && TYPE="dir"
echo " $f ($TYPE, $SIZE)"
done
echo ""
read -rp " Remove extra files? [y/N] " REMOVE
if [[ "$REMOVE" =~ ^[Yy]$ ]]; then
echo "$EXTRA_FILES" | while read -r f; do
echo " Removing: $f"
ssh "$LXC" "rm -rf '$REMOTE_PORTAL/$f'"
done
echo " Done."
else
echo " Kept extra files."
fi
fi
echo ""
echo "══════════════════════════════════════════════════════════════"
echo "Done. Portal files at http://$(echo "$LXC" | cut -d@ -f2):5000/files/"
echo "Note: Add splash.png to $REMOTE_FIRST_BOOT/ (or plymouth-custom/) if you want a custom boot splash."
echo "══════════════════════════════════════════════════════════════"