#!/bin/bash images="root@192.168.26.134:/virtual/images/" kickstart="http://ufo.kit.edu/ands/kickstart/" #inst.stage2 in isolinux.cfg needs to match the label of ISO, to get lable use 'file ' or 'isoinfo -d -i ' #Lantronix Spider does not provide CDROM labels (we can add inst.stage2=cdrom, but this may break booting on multicd systems) centos74_label="CentOS 7 x86_64" centos75_label="CentOS 7 x86_64" fedora28_label="Fedora-S-dvd-x86_64-28" die() { echo "$*" 1>&2 ; exit 1; } usage() { echo "Usage: $0 [--cdrom]"; } [ $# -gt 0 ] || { usage; exit 1; } distrib=$(echo $1 | grep -oP '[\w\d_\-]+') label_arg=$(echo ${distrib}_label) label_std=${!label_arg} [ -d $distrib ] || die "$distrib is not found" [ -n "$label_std" ] || die "Label for $distrib is not configured" shift ver=1 rhver=$(echo $distrib | grep -oP '\d+') dname=$(echo $distrib | grep -oP '[^\d]+') extra="" isoname="$distrib-ands$(if [ $ver -gt 1 ]; then echo $ver ; fi)" while [ $# -gt 0 ]; do case "$1" in --cdrom) media=$(if [[ "$2" =~ ^[[:alnum:]] ]]; then echo $2; else echo "cdrom"; fi) extra="$extra inst.stage2=$media" isoname="$isoname-$media" echo $media shift $(if [[ "$2" =~ ^[[:alnum:]] ]]; then echo 2; else echo 1; fi) ;; h | *) usage; exit 0 ;; esac done isolinux="isolinux-${distrib}.cfg" [ -f $isolinux ] || isolinux="isolinux-${dname}.cfg" [ -f $isolinux ] || die "Configuration $isolinux is not found" echo "Building ${isoname}.iso with extra parameters \"$extra\" and the label \"$label_std\"" echo "Using configuration: $isolinux" #Generating config chmod +w $distrib/isolinux chmod +w $distrib/isolinux/isolinux.cfg sed -e "s/@EXTRA@/$extra/g" -e "s/@KICKSTART@/$kickstart/g" $isolinux > $distrib/isolinux/isolinux.cfg || die "Can't overwrite the configuration" #Creating output folder mkdir -p iso #Building ISO ( cd $distrib || die "Can't chdir" chmod 664 isolinux/isolinux.bin rm -f iso/${isoname}.iso # On Forums Disc1 label is recommended, but it is not recognized (at least by Fedora) # mkisofs -o ../iso/${isoname}.iso -A "$label_std" -V "$label_std Disc 1" -volset "$label_std" \ mkisofs -o ../iso/${isoname}.iso -A "$label_std" -V "$label_std" -volset "$label_std" \ -U -J -joliet-long -r -v -T \ -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table \ -eltorito-alt-boot -e images/efiboot.img -no-emul-boot \ . ) #Installing scp iso/${isoname}.iso $images