Files
reterminal-dm4/emmc-provisioning/scripts/sync-portal-files-to-lxc.sh
nearxos 16c796b8af Refactor first-boot process to introduce ordered execution and new one-shot scripts
Revise the first-boot script to implement a structured approach with 13 numbered steps, allowing for better control over the execution order. Introduce two new one-shot scripts: `01-set-rotation-once.sh` and `02-set-wallpaper-once.sh`, replacing the previous single script approach. Update documentation to reflect these changes, including the new configuration options for enabling/disabling steps and the revised file structure for one-shot scripts. Enhance the dashboard to display first-boot progress, improving user feedback during the initial setup.
2026-02-22 16:22:44 +02:00

66 lines
2.9 KiB
Bash
Executable File

#!/usr/bin/env bash
# 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.
#
# Usage: ./sync-portal-files-to-lxc.sh [user@lxc_ip]
# Example: ./sync-portal-files-to-lxc.sh root@10.130.60.141
set -e
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"
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"
exit 1
fi
echo "Syncing portal files to $LXC ($REMOTE_PORTAL) ..."
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
# --- 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/"
# Kiosk and scripts
rsync -avz \
"$CLOUDINIT_DIR/start-chromium.sh" \
"$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/"
# 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/"
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."