-# GRUB CONFIG {{{
-function grubConfig
-{
- local tmp_=`mktemp -td terminalserver_grub.XXXXXX` || warn "could not create tmp file for grubConfig"
- if [ -z "$tmp_" ]; then return 1; fi
-
- grubConfigWork $tmp_
- local ret_=$?
- execute "rm -rf $tmp_" warn
-
- return $ret_
-}
-
-function grubConfigWork
-{
- local tmp_="$1"
-
- local grub_title_="Grub configuration"
- local grub_nic_message_="
-Give me the types of network cards you would want to boot from.
-If you networkcard is already listed press <OK>!
-
-WARNING: DON't add all NIC's, grub could possibly stop working!!"
- local nics_=""
-
- while read module_ desc_ mode_; do
- nics_="$nics_ $module_ $desc_ $mode_"
- done < $GRUB_NIC_CONF_
-
- echo -n "" >$TMP_
- local cmd_line_=""
- $DIALOG_ --clear --separate-output --backtitle "$BACK_TITLE_" --title "$grub_title_" --checklist \
- "$grub_nic_message_" 10 70 0 $nics_ 2>$TMP_
- local ret_=$?
- if [[ $ret_ -ne 0 || `wc -l <$TMP_` -eq 0 ]]; then
- echo $ret_
- warn "you should give me your specified NICs but didn't => DEFAULT will be used"
- awk '/ on$/{print $1}' $GRUB_NIC_CONF_ >$TMP_
- fi
- while read module_; do
- cmd_line_="$cmd_line_ --enable-$module_"
- done < $TMP_
-
- echo "\"$cmd_line_\""
-
- execute "tar xzf $GRUB_SOURCE_ -C $tmp_" warn || return 1
- execute "cd $tmp_/grub*" warn || return 1
-cat >preset-menu <<EOT
-# Set up the serial terminal, first of all.
-#serial --unit=0 --speed=19200
-#terminal --timeout=0 serial
-
-# Initialize the network.
-#dhcp --with-configfile
-#bootp --with-configfile
-dhcp
-default 0
-timeout 0
-title Load config from Tftp server
- configfile (nd)/menu.lst
-EOT
- #execute "./configure --enable-diskless --enable-preset-menu=./preset-menu $cmd_line_" warn || read
- execute "CC=gcc-3.3 ./configure --enable-preset-menu=./preset-menu $cmd_line_" warn || read
- execute "make -j2 CC=gcc-3.3" warn || read #return 1
-
- local st1_="stage1/stage1"
- local st2_="stage2/stage2"
- isExistent $st1_ warn || return 1
- isExistent $st2_ warn || return 1
-
- execute "mv -fb $PATH_/grub.img $PATH_/grub.img.old"
- execute "cat $st1_ $st2_ > $PATH_/grub.img" warn || return 1
- return 0
-}
-
-function grubWrite
-{
- local grub_title_="Grub configuration"
- $DIALOG_ --clear --backtitle "$BACK_TITLE_" --title "$grub_title_" --yesno \
- "Do you want to write your grub image to /dev/fd0" 5 75 || return 1
-
- execute "dd if=$PATH_/grub.img of=/dev/fd0" warn || return 0
- return 1
-}
-
-function grubMultiWrite
-{
- local target_=${1:-'/dev/fd0'}
-
- isExistent "$PATH_/grub.img" die "you must give me an image or run \"$PROG_NAME__ grubconf\""
- isExistent "$target_" die "$target_ is not a valied"
- while true; do
- echo -n "Please insert disk into $target_ and press <ENTER> (STRG-C for end)"
- read
- dd if=$PATH_/grub.img of="$target_"
- done
-}
-# }}}
-