packer-hcloud/scripts/10-prepare-kickstart.sh
Robert Kaussow 78e049f6e0
Some checks failed
continuous-integration/drone/push Build is failing
initial commit
2022-09-08 15:13:44 +02:00

36 lines
928 B
Bash

#!/usr/bin/env bash
set -e
### Install requirements
export DEBIAN_FRONTEND=noninteractive
apt-get -qq update && apt-get -qq -y install grub-pc
### Wipe all partitions on the existing disk
wipefs -q --all --force /dev/sda
### Create and partition to allow kickstarts
parted -s /dev/sda mklabel msdos
parted -s /dev/sda mkpart primary 4M 200M
mkfs.ext4 -q -L OEMDRV /dev/sda1
mount /dev/sda1 /boot
### Download kernel and installer initrd to kickstart partition
curl -SsfL -o /boot/vmlinuz "$BUILD_MIRROR/BaseOS/x86_64/os/isolinux/vmlinuz"
curl -SsfL -o /boot/initrd.img "$BUILD_MIRROR/BaseOS/x86_64/os/isolinux/initrd.img"
### Install and configure Grub to load the installer initrd
grub-install --no-floppy /dev/sda
cat >/boot/grub/grub.cfg <<EOF
set default=0
set timeout=5
menuentry "Kickstart Rocky Linux" {
set root=(hd0,1)
linux /vmlinuz ip=dhcp
initrd /initrd.img
}
EOF
mv /root/ks.cfg /boot/ks.cfg
shutdown -r now