BASH   17

mkdvdiso sh

Guest on 25th January 2023 01:53:24 AM


  1. #/bin/bash
  2.  
  3. # by Chris Kloiber <ckloiber@redhat.com>
  4.  
  5. # A quick hack that will create a bootable DVD iso of a Red Hat Linux
  6. # Distribution. Feed it either a directory containing the downloaded
  7. # iso files of a distribution, or point it at a directory containing
  8. # the "RedHat", "isolinux", and "images" directories.
  9.  
  10. # This version only works with "isolinux" based Red Hat Linux versions.
  11.  
  12. # Lots of disk space required to work, 3X the distribution size at least.
  13.  
  14. # GPL version 2 applies. No warranties, yadda, yadda. Have fun.
  15.  
  16.  
  17. if [ $# -lt 2 ]; then
  18.         echo "Usage: `basename $0` source /destination/DVD.iso"
  19.         echo ""
  20.         echo "        The 'source' can be either a directory containing a single"
  21.         echo "        set of isos, or an exploded tree like an ftp site."
  22.         exit 1
  23. fi
  24.  
  25. cleanup() {
  26. [ ${LOOP:=/tmp/loop} = "/" ] && echo "LOOP mount point = \/, dying!" && exit
  27. [ -d $LOOP ] && rm -rf $LOOP
  28. [ ${DVD:=~/mkrhdvd} = "/" ] && echo "DVD data location is \/, dying!" && exit
  29. [ -d $DVD ] && rm -rf $DVD
  30. }
  31.  
  32. cleanup
  33. mkdir -p $LOOP
  34. mkdir -p $DVD
  35.  
  36. if [ !`ls $1/*.iso 2>&1>/dev/null ; echo $?` ]; then
  37.         echo "Found ISO CD images..."
  38.         CDS=`expr 0`
  39.         DISKS="1"
  40.  
  41.         for f in `ls $1/*.iso`; do
  42.                 mount -o loop $f $LOOP
  43.                 cp -av $LOOP/* $DVD
  44.                 if [ -f $LOOP/.discinfo ]; then
  45.                         cp -av $LOOP/.discinfo $DVD
  46.                         CDS=`expr $CDS + 1`
  47.                         if [ $CDS != 1 ] ; then
  48.                                 DISKS=`echo ${DISKS},${CDS}`
  49.                         fi
  50.                 fi
  51.                 umount $LOOP
  52.         done
  53.         if [ -e $DVD/.discinfo ]; then
  54.                 awk '{ if ( NR == 4 ) { print disks } else { print ; } }' disks="$DISKS" $DVD/.discinfo > $DVD/.discinfo.new
  55.                 mv $DVD/.discinfo.new $DVD/.discinfo
  56.         fi
  57. else
  58.         echo "Found FTP-like tree..."
  59.         cp -av $1/* $DVD
  60.         [ -e $1/.discinfo ] && cp -av $1/.discinfo $DVD
  61. fi
  62.  
  63. rm -rf $DVD/isolinux/boot.cat
  64. find $DVD -name TRANS.TBL | xargs rm -f
  65.  
  66. cd $DVD
  67. mkisofs -J -R -v -T -o $2 -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table .
  68. /usr/lib/anaconda-runtime/implantisomd5 --force $2
  69.  
  70. cleanup
  71. echo ""
  72. echo "Process Complete!"
  73. echo ""

Raw Paste


Login or Register to edit or fork this paste. It's free.

">