diff --git a/build-iso.sh b/build-iso.sh old mode 100644 new mode 100755 index 88d709e..cf0019b --- a/build-iso.sh +++ b/build-iso.sh @@ -19,7 +19,7 @@ set -euo pipefail UBUNTU_ISO="${UBUNTU_ISO:-}" -UBUNTU_VERSION="24.04" +UBUNTU_VERSION="24.04.4" UBUNTU_ISO_URL="https://releases.ubuntu.com/${UBUNTU_VERSION}/ubuntu-${UBUNTU_VERSION}-live-server-amd64.iso" WORK_DIR="$(mktemp -d /tmp/autoinstall-build.XXXXXX)" OUTPUT_ISO="autoinstall-$(date +%Y%m%d-%H%M).iso" @@ -81,19 +81,27 @@ if grep -qE '\$\{[A-Z_]+\}' "$RENDERED_FILE"; then fi info "Template rendered." -# ── Get Ubuntu ISO ───────────────────────────────────────────────────────────── -if [[ -z "$UBUNTU_ISO" ]]; then +if [[ -n "$UBUNTU_ISO" ]]; then + # User provided a path — validate it exists + [[ -f "$UBUNTU_ISO" ]] || error "ISO not found: $UBUNTU_ISO" + info "Using provided ISO: $UBUNTU_ISO" +else + # Auto mode — use default name, download if missing + # UBUNTU_ISO="ubuntu-${UBUNTU_VERSION}-desktop-amd64.iso" UBUNTU_ISO="ubuntu-${UBUNTU_VERSION}-live-server-amd64.iso" if [[ ! -f "$UBUNTU_ISO" ]]; then info "Downloading Ubuntu ${UBUNTU_VERSION} server ISO..." - curl -L --progress-bar -o "$UBUNTU_ISO" "$UBUNTU_ISO_URL" + curl -L --fail --progress-bar -o "$UBUNTU_ISO" "$UBUNTU_ISO_URL" || + { + rm -f "$UBUNTU_ISO" + error "Download failed (check URL or network): $UBUNTU_ISO_URL" + } else info "Found cached ISO: $UBUNTU_ISO" fi fi -[[ -f "$UBUNTU_ISO" ]] || error "ISO not found: $UBUNTU_ISO" -# ── Extract ISO ──────────────────────────────────────────────────────────────── +# ── Extract ISO + MBR template ──────────────────────────────────────────────── info "Extracting ISO..." xorriso -osirrox on -indev "$UBUNTU_ISO" -extract / "$WORK_DIR/iso" 2>/dev/null chmod -R u+w "$WORK_DIR/iso" @@ -106,15 +114,6 @@ cp "$RENDERED_FILE" "$NOCLOUD_DIR/user-data" cp "$POST_INSTALL_SCRIPT" "$NOCLOUD_DIR/post-install.sh" touch "$NOCLOUD_DIR/meta-data" -# The installer runs in a live env where the ISO is mounted at /cdrom. -# post-install.sh lands at /cdrom/nocloud/post-install.sh but curtin in-target -# runs inside the installed system chroot, so we copy it to /target first. -# We add a prep command to late-commands via a second write — easier to just -# add a copy step before the main script call in user-data. We handle it here -# by prepending a cp command as an additional late-command note: -# (already handled in user-data.tmpl with: curtin in-target -- bash /post-install.sh -# which works because the file is written to /target by the nocloud datasource) - # ── Patch GRUB ──────────────────────────────────────────────────────────────── GRUB_CFG="$WORK_DIR/iso/boot/grub/grub.cfg" if [[ -f "$GRUB_CFG" ]]; then @@ -125,18 +124,6 @@ fi # ── Repack ISO ───────────────────────────────────────────────────────────────── info "Repacking ISO → $OUTPUT_ISO ..." -xorriso -as mkisofs \ - -r -V "Ubuntu-AutoInstall" -o "$OUTPUT_ISO" \ - -J -joliet-long \ - -b boot/grub/i386-pc/eltorito.img -c boot.catalog \ - -no-emul-boot -boot-load-size 4 -boot-info-table \ - --grub2-boot-info \ - --grub2-mbr "$WORK_DIR/iso/boot/grub/i386-pc/boot_hybrid.img" \ - -eltorito-alt-boot \ - -e --interval:appended_partition_2:all:: -no-emul-boot \ - -append_partition 2 28732ac11ff8d211ba4b00a0c93ec93b "$WORK_DIR/iso/boot/grub/efi.img" \ - -iso_mbr_part_type a2a0d0ebe5b9334487c068b6b72699c7 \ - "$WORK_DIR/iso" 2>/dev/null info "Done! ✓" echo "" diff --git a/run.sh b/run.sh new file mode 100644 index 0000000..c68ed72 --- /dev/null +++ b/run.sh @@ -0,0 +1 @@ +./build-iso.sh --ubuntu-iso $(pwd)/ubuntu-*.iso diff --git a/scripts/post-install.sh b/scripts/post-install.sh index 1ab460c..2fb1276 100755 --- a/scripts/post-install.sh +++ b/scripts/post-install.sh @@ -16,6 +16,17 @@ error() { exit 1 } +# ─── DESKTOP ───────────────────────────────────────────────────────────────── +info "Installing GNOME desktop (minimal)..." +DEBIAN_FRONTEND=noninteractive apt-get install -y \ + ubuntu-desktop-minimal \ + gnome-tweaks \ + gnome-terminal \ + firefox \ + nautilus +systemctl set-default graphical.target +info "Desktop installed." + # ─── DOCKER ────────────────────────────────────────────────────────────────── info "Installing Docker..." install -m 0755 -d /etc/apt/keyrings