diff --git a/unattended.sh b/unattended.sh index 8c315b1..e788ed2 100755 --- a/unattended.sh +++ b/unattended.sh @@ -1,25 +1,34 @@ #!/usr/bin/env bash +# Get the file name ISONAME=$(ls | grep "netinst.iso" | sort | tail -n1) +# Remove an already existing unattended iso of this same version, if existing rm -f $(echo ${ISONAME} | sed 's/netinst/unattended/') +# Extract iso files xorriso -osirrox on -indev ${ISONAME} -extract / isofiles +# Remove the grub menu sudo sed -i '/vesamenu.c32/d' isofiles/isolinux/isolinux.cfg +# Fix the grub menu if [[ $(grep timeout_style isofiles/boot/grub/grub.cfg) == "" ]]; then sudo sed -i 's/insmod play/set timeout_style=hidden\nset timeout=0\nset default=1\n\ninsmod play/' isofiles/boot/grub/grub.cfg; fi +# Extract the initrd image, put the preseed file in int, and re-compress chmod +w -R isofiles/install.amd/ gunzip isofiles/install.amd/initrd.gz echo preseed.cfg | cpio -H newc -o -A -F isofiles/install.amd/initrd gzip isofiles/install.amd/initrd chmod -w -R isofiles/install.amd/ +# Recreate the md5sum check file cd isofiles/ chmod a+w md5sum.txt md5sum $(find -follow -type f) > md5sum.txt chmod a-w md5sum.txt cd .. +# Repackage all the iso files chmod a+w isofiles/isolinux/isolinux.bin docker run --interactive --tty --rm --volume $(pwd):/root/unattended debian:buster /root/unattended/docker.sh +# Remove the extracted (temporary) files sudo rm -rf isofiles