1 #!/bin/bash 2 # 3 # Generate a syslinux floppy that loads a gPXE image 4 # 5 # gensdsk foo.sdsk foo.lkrn 6 # 7 # the floppy image is the first argument 8 # followed by list of .lkrn images 9 # 10 11 case $# in 12 0|1) 13 echo Usage: $0 foo.sdsk foo.lkrn ... 14 exit 1 15 ;; 16 esac 17 case "`mtools -V`" in 18 Mtools\ version\ 3.9.9*|Mtools\ version\ 3.9.1[0-9]*|[mM]tools\ *\ [4-9].*) 19 ;; 20 *) 21 echo Mtools version 3.9.9 or later is required 22 exit 1 23 ;; 24 esac 25 img=$1 26 shift 27 dir=`mktemp -d bin/sdsk.dir.XXXXXX` 28 29 mformat -f 1440 -C -i $img :: 30 cfg=$dir/syslinux.cfg 31 cat > $cfg <<EOF 32 33 # These default options can be changed in the gensdsk script 34 TIMEOUT 30 35 EOF 36 first= 37 for f 38 do 39 if [ ! -r $f ] 40 then 41 echo $f does not exist, skipping 1>&2 42 continue 43 fi 44 # shorten name for 8.3 filesystem 45 b=$(basename $f) 46 g=${b%.lkrn} 47 g=${g//[^a-z0-9]} 48 g=${g:0:8}.krn 49 case "$first" in 50 "") 51 echo DEFAULT $g 52 ;; 53 esac 54 first=$g 55 echo LABEL $b 56 echo "" KERNEL $g 57 mcopy -m -i $img $f ::$g 58 done >> $cfg 59 mcopy -i $img $cfg ::syslinux.cfg 60 if ! syslinux $img 61 then 62 exit 1 63 fi 64 65 rm -fr $dir 66