#! /bin/sh -e # update-grub helper script. # if [ -x "`which os-prober 2>/dev/null`" ] ; then # os-prober output contains the partition and the name, a label and # a boot keyword, separated by colons (:) for each detected OS. # It may contain space characters and linebreaks, # e.g. "/dev/hda2:Windows XP Professional:Windows:chain". # Convert space characters to underscores and linebreaks to spaces. RESULT="`os-prober | tr ' ' '_' | tr '\n' ' '`" fi if [ "x${RESULT}" != "x" ] ; then for OS in "${RESULT}" ; do # e.g. "/dev/hda2:Windows_XP_Professional:Windows:chain" PARTITION="`echo ${OS} | cut -d ':' -f 1`" LONGNAME="`echo ${OS} | cut -d ':' -f 2 | tr '_' ' '`" LABEL="`echo ${OS} | cut -d ':' -f 3`" BOOT="`echo ${OS} | cut -d ':' -f 4`" if [ "x${LONGNAME}" = "x" ] ; then # is this likely to happen? LONGNAME="${LABEL}" fi case "${BOOT}" in chain) echo "Found ${LONGNAME} on ${PARTITION}" >&2 if [ -x "`which grub-probe 2>/dev/null`" ] ; then # need to convert partition device to GRUB drive here! GRUB_DEVICE="`grub-probe --something ${PARTITION}`" cat << EOF menuentry "${LONGNAME} (on ${PARTITION})" { set root=${GRUB_DEVICE} chainloader +1 } EOF else # wtf?! echo " Error: Missing grub-probe!" >&2 fi ;; macos|macosx) # can't macos* also be chainloaded? ;; hurd|linux) # other Linux/HURD-Systems are not (yet) supported # with the given output of os-prober ;; *) # is it possible to reach here? ;; esac done fi