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 11case $# in 120|1) 13 echo Usage: $0 foo.sdsk foo.lkrn ... 14 exit 1 15 ;; 16esac 17case "`mtools -V`" in 18Mtools\ 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 ;; 24esac 25img=$1 26shift 27dir=`mktemp -d bin/sdsk.dir.XXXXXX` 28 29mformat -f 1440 -C -i $img :: 30cfg=$dir/syslinux.cfg 31cat > $cfg <<EOF 32 33# These default options can be changed in the gensdsk script 34TIMEOUT 30 35EOF 36first= 37for f 38do 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 58done >> $cfg 59mcopy -i $img $cfg ::syslinux.cfg 60if ! syslinux $img 61then 62 exit 1 63fi 64 65rm -fr $dir 66