#!/usr/bin/bash

touch test.ks
mkdir -p /mnt/iso /mnt/isopart

for iso in $@; do
    mod_iso="${iso}-mkksiso.iso"
    echo -e "${iso}:\n======================================================\nPARTED - ORIGINAL ISO:"
    parted -s ${iso} print

    echo -e "\nMKKSISO:"
    mkksiso -c "testparam" -r "rd.live.check" test.ks ${iso} ${mod_iso}

    echo -e "\nPARTED - MODIFIED ISO:"
    parted -s ${mod_iso} print

    iso_loop=$(losetup -f ${mod_iso} --show)
    partprobe ${iso_loop}
    mount ${iso_loop} /mnt/iso

    echo -e "\nBOOT ENTRIES IN MODIFIED ISO (ISO9660 FS):"
    find /mnt/iso -iname grub*.cfg | xargs grep -E "linuxefi|\s*linux /"
    umount /mnt/iso

    echo -e "\nBOOT ENTRIES IN MODIFIED ISO - PARTITIONS:"
    for part in ${iso_loop}p*; do
        echo "PARTITION: ${part}"
        mount ${part} /mnt/isopart
        find /mnt/isopart -iname grub*.cfg | xargs grep -E "linuxefi|\s*linux /"
        umount /mnt/isopart
    done
    echo -e "\n\n\n\n\n"
done

