Files
nova-os/firstboot/nova-firstboot
T
blazblue547-afk 79f80c645d 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
2026-06-14 13:01:34 -04:00

53 lines
2.1 KiB
Bash
Executable File

#!/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