#!/bin/sh set -e exec >/boot/waouw-stage-init.log 2>&1 echo "== waouw-stage-init (PID1) start: $(date) ==" # Determine source boot dir SRC_BOOT="/boot" if [ -d "/boot/firmware" ] && [ -f "/boot/firmware/waouw-firstboot.service" ]; then SRC_BOOT="/boot/firmware" fi echo "Using SRC_BOOT=$SRC_BOOT" # Deploy service and scripts into systemd mkdir -p /etc/systemd/system /etc/systemd/system/multi-user.target.wants cp "$SRC_BOOT/waouw-firstboot.service" /etc/systemd/system/waouw-firstboot.service chmod 0644 /etc/systemd/system/waouw-firstboot.service INSTALL_SCRIPT="$SRC_BOOT/waouw-install.sh" chmod +x "$INSTALL_SCRIPT" 2>/dev/null || true # Enable service via symlink (systemctl not available yet) ln -sf /etc/systemd/system/waouw-firstboot.service \ /etc/systemd/system/multi-user.target.wants/waouw-firstboot.service ## Keep it minimal: no mounts, no apt here; firstboot service will handle install echo "Cleaning cmdline to avoid re-running on next boot" # Try to clean from either /boot or /boot/firmware for BOOTDIR in /boot /boot/firmware; do if [ -f "$BOOTDIR/cmdline.txt" ]; then # Remove our flags safely (match with a leading space) sed -i \ -e 's| systemd.run=[^ ]*||g' \ -e 's| systemd.run_success_action=[^ ]*||g' \ -e 's| systemd.unit=[^ ]*||g' \ "$BOOTDIR/cmdline.txt" || true echo "cmdline cleaned in $BOOTDIR" echo "ok" > "$BOOTDIR/waouw-stage-init.ok" || true fi done sync echo "Stage-init complete; letting success_action=reboot take over" sync sleep 1 exit 0