I attached a variant of 60_grub-imageboot with the following changes
 * Make stripping filename extentions more robust.
 * Improve quoting.
 * Refactor.

This is based on the packages git head with additionally
http://grml.org/patches/0001-Probe-device-where-image-is-being-stored-using-grub_.patch
applied.


* Carsten Hey [2011-06-24 11:49 +0200]:
> Two ways to make grub-imageboot more configurable that come to my mind
> are:
>  * read options for ${imagefile} from ${imagefile}.config if it exists
>  * let the users add additional file name extensions with custom options
>    in /etc/default/grub-imageboot, e.g., .raw-hdd, which uses "raw" and
>    "harddisk" as options

 * a new config file with the following syntax (lines starting with
   # could be ignored):
   [FILENAME] [OPTION] ...


Regards
Carsten
#!/bin/sh
# (c) 2010 Alexander Wirt <[email protected]>
# 
# The general idea for this script got collected from several blog entrys
# and the syslinux wiki. If you think you should get mentioned in the authors
# or copyright file, please tell me :). 
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

set -e

IMAGES=/boot/images

if [ -e "/etc/default/grub-imageboot" ]
then
        . /etc/default/grub-imageboot
fi

. /usr/lib/grub/grub-mkconfig_lib

imageboot_add() {
        local extension="$1"
        local options="$2"
        local message_txt="$3"
        local menu_txt="$4"

        echo "$message_txt: $image" >&2
        cat << EOF
menuentry "$menu_txt: $(basename "$IMAGEPATH" | sed -e "s/[.]$extension\$//")" {
EOF
        prepare_grub_to_access_device "$($grub_probe -t device "$image")" | sed 
-e "s/^/\t/"
        cat << EOF
        linux16 $MEMDISKPATH $options
        initrd16 $IMAGEPATH
}
EOF
}

if test -e /boot/memdisk ; then
        MEMDISKPATH=$( make_system_path_relative_to_its_root "/boot/memdisk" )
        echo "Found memdisk: $MEMDISKPATH" >&2
        if [ ! -d "$IMAGES" ]; then
                echo "Imagepath $IMAGES not found" >&2
                exit
        fi
        find "$IMAGES" -name '*.iso' -o -name '*.img' | sort |
        while read image ; do
                IMAGEPATH=$( make_system_path_relative_to_its_root "$image" )
                case "$image" in
                        *.iso)
                                imageboot_add "iso" "${ISOOPTS:-iso}"      
"Found iso image"    "Bootable ISO Image"
                                ;;
                        *.img)
                                imageboot_add "img" "${IMAGEOPTS:-rawimg}" 
"Found floppy image" "Bootable Floppy Image"
                                ;;
                esac
        done
else 
        echo "memdisk not found" >&2
        echo "Please copy /usr/lib/syslinux/memdisk to /boot/memdisk" >&2 
fi

Reply via email to