Skip to content

Instantly share code, notes, and snippets.

@Nothing4You
Created September 30, 2020 09:42
Show Gist options
  • Save Nothing4You/32e9047da2f234a94a703625a9c62c1a to your computer and use it in GitHub Desktop.
Save Nothing4You/32e9047da2f234a94a703625a9c62c1a to your computer and use it in GitHub Desktop.
centos embed kickstart in iso
#!/usr/bin/env bash
# dependencies: bsdtar xorriso isomd5sum
iso="CentOS-8.2.2004-x86_64-boot.iso"
#iso="CentOS-8.2.2004-x86_64-dvd1.iso"
ks="./kickstart-centos8.cfg"
wd="isobuild"
ks="$(realpath "$ks")"
mkdir -p "$wd"
newiso="${iso%.*}-kickstart-template.iso"
echo "Working in $wd"
cd "$wd"
test -f "$iso" || curl -Lo "$iso" "https://mirror.netcologne.de/centos/8/isos/x86_64/$iso"
test -f "$newiso" && rm -v "$newiso"
test -d cd && rm -rf cd
mkdir cd
bsdtar -C cd/ -xf "$iso"
sed -ri 's|^timeout [0-9]+|timeout 50|' cd/isolinux/isolinux.cfg
sed -i 's|rd.live.check|rd.live.check text inst.ks=cdrom:/ks.cfg inst.loglevel=debug|' cd/isolinux/isolinux.cfg
cp -a "$ks" cd/ks.cfg
mkisofs -J -joliet-long -V "CentOS-8-BaseOS-x86_64" -volset "CentOS-8-BaseOS-x86_64" -A "CentOS-8-BaseOS-x86_64" -U -o "$newiso" -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -v cd/
implantisomd5 "$newiso"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment