From 79f80c645d488b645066a631f0e4f119c91aac31 Mon Sep 17 00:00:00 2001 From: blazblue547-afk Date: Sun, 14 Jun 2026 13:01:34 -0400 Subject: [PATCH] v4.2: first-boot auto-expand, SSH key regeneration, forced password change - Added nova-firstboot systemd service (runs once on first boot) - Auto-expands root partition to fill SD card (fdisk + resize2fs) - Removes pre-generated SSH host keys (sshd regenerates fresh) - Forces root password change on first login (shadow last_change=0) - Compiled e2fsprogs 1.47.2 from source for resize2fs - Updated os-release, motd, and build script --- firstboot/motd | 11 +++++++ firstboot/nova-firstboot | 52 ++++++++++++++++++++++++++++++++ firstboot/nova-firstboot.service | 17 +++++++++++ firstboot/os-release | 6 ++++ firstboot/shadow.template | 1 + mkimage.sh | 2 +- 6 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 firstboot/motd create mode 100755 firstboot/nova-firstboot create mode 100644 firstboot/nova-firstboot.service create mode 100644 firstboot/os-release create mode 100644 firstboot/shadow.template diff --git a/firstboot/motd b/firstboot/motd new file mode 100644 index 0000000..e1078c5 --- /dev/null +++ b/firstboot/motd @@ -0,0 +1,11 @@ + + ╔══════════════════════════════════════════╗ + ║ N O V A O S ║ + ║ "Burn bright, run light." ║ + ║ 100% from source — zero prebuilt ║ + ║ systemd 260 · glibc 2.41 · BusyBox ║ + ║ OpenSSH 10.3 · firstboot auto-expand ║ + ╚══════════════════════════════════════════╝ + + GitHub: https://github.com/blazblue547-afk/nova-os + diff --git a/firstboot/nova-firstboot b/firstboot/nova-firstboot new file mode 100755 index 0000000..2b18866 --- /dev/null +++ b/firstboot/nova-firstboot @@ -0,0 +1,52 @@ +#!/bin/sh +# Nova OS — First Boot Setup +# Expands root partition, regenerates SSH keys, expires root password + +set -e + +FLAG=/etc/nova-firstboot-done +if [ -f "$FLAG" ]; then + exit 0 +fi + +echo "" +echo " ╔══════════════════════════════════════════╗" +echo " ║ Nova OS — First Boot Setup ║" +echo " ╚══════════════════════════════════════════╝" +echo "" + +# ── 1. Expand root partition to fill SD card ────────────────── +PART=/dev/mmcblk0p2 +DISK=/dev/mmcblk0 + +echo "==> Expanding root partition to fill SD card..." +printf "d\n2\nn\np\n2\n\n\nw\n" | fdisk "$DISK" > /dev/null 2>&1 +blockdev --rereadpt "$DISK" 2>/dev/null || true +sleep 1 + +# ── 2. Grow ext4 filesystem ─────────────────────────────────── +echo "==> Resizing root filesystem..." +resize2fs "$PART" + +# ── 3. Regenerate SSH host keys ─────────────────────────────── +echo "==> Generating fresh SSH host keys..." +rm -f /etc/ssh/ssh_host_*_key /etc/ssh/ssh_host_*_key.pub + +# ── 4. Force root password change on first login ────────────── +echo "==> Securing root account..." +passwd -e root 2>/dev/null || true + +# ── 5. Mark first-boot complete ─────────────────────────────── +touch "$FLAG" +sync + +echo "" +echo " ╔══════════════════════════════════════════╗" +echo " ║ First-boot setup complete. ║" +echo " ║ Root password must be changed. ║" +echo " ║ Rebooting in 5 seconds... ║" +echo " ╚══════════════════════════════════════════╝" +echo "" + +sleep 5 +reboot diff --git a/firstboot/nova-firstboot.service b/firstboot/nova-firstboot.service new file mode 100644 index 0000000..1c72777 --- /dev/null +++ b/firstboot/nova-firstboot.service @@ -0,0 +1,17 @@ +[Unit] +Description=Nova OS First-Boot Setup +Documentation=https://github.com/blazblue547-afk/nova-os +After=local-fs.target +Before=sshd.service network.target multi-user.target +ConditionPathExists=!/etc/nova-firstboot-done + +[Service] +Type=oneshot +ExecStart=/usr/sbin/nova-firstboot +StandardOutput=journal+console +StandardError=journal+console +RemainAfterExit=yes +TimeoutSec=300 + +[Install] +WantedBy=multi-user.target diff --git a/firstboot/os-release b/firstboot/os-release new file mode 100644 index 0000000..3687175 --- /dev/null +++ b/firstboot/os-release @@ -0,0 +1,6 @@ +NAME="Nova OS" +VERSION="4.2-firstboot" +ID=nova-os +PRETTY_NAME="Nova OS 4.2" +VERSION_ID="4.2" +HOME_URL="https://github.com/blazblue547-afk/nova-os" diff --git a/firstboot/shadow.template b/firstboot/shadow.template new file mode 100644 index 0000000..41000ab --- /dev/null +++ b/firstboot/shadow.template @@ -0,0 +1 @@ +root:$6$4FERwZD4bnOFP1wz$0onBXYHLu822Hk1SQxB0Nbh/OvrI5ja29Fzmv8Gfe7E3eMfnplVA88SK/lV24Zx/nuhUZy1HeW3Q.WbvaLHgx0:0:0:99999:7::: diff --git a/mkimage.sh b/mkimage.sh index 98df34a..823fd0b 100755 --- a/mkimage.sh +++ b/mkimage.sh @@ -5,7 +5,7 @@ set -e NOVA_ROOT="/home/joe/nova-os" -IMAGE="$NOVA_ROOT/nova-os-4.1-ssh.img" +IMAGE="$NOVA_ROOT/nova-os-4.2-firstboot.img" SIZE_MB=1536 # 1.5 GB TMP_MNT="/tmp/nova-os-mnt"