home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / lib / linux-boot-probes / mounted / 40grub next >
Encoding:
Text File  |  2006-08-21  |  1.5 KB  |  85 lines

  1. #!/bin/sh
  2. . /usr/share/os-prober/common.sh
  3. set -e
  4.  
  5. partition="$1"
  6. bootpart="$2"
  7. mpoint="$3"
  8. type="$4"
  9.  
  10. found_item=0
  11.  
  12. entry_result () {
  13.     if [ -n "$kernel" ] && \
  14.        [ -e "$mpoint/$kernel" ]; then
  15.         result "$rootpart:$bootpart:$title:$kernel:$initrd:$parameters"
  16.         found_item=1
  17.     fi
  18.     kernel=""
  19.     parameters=""
  20.     initrd=""
  21.     title=""
  22. }
  23.  
  24. parse_grub_menu () {
  25.     mpoint="$1"
  26.     rootpart="$2"
  27.     bootpart="$3"
  28.     
  29.     kernel=""
  30.     parameters=""
  31.     initrd=""
  32.     title=""
  33.  
  34.     while read line; do
  35.         debug "parsing: $line"
  36.         set -- $line
  37.         case "$1" in
  38.             title)
  39.                 entry_result
  40.                 shift 1
  41.                 title="$(echo $@ | sed 's/://g')"
  42.             ;;
  43.             kernel)
  44.                 # Hack alert: sed off any (hdn,n) but
  45.                 # assume the kernel is on the same
  46.                 # partition.
  47.                 kernel="$(echo $2 | sed 's/(.*)//')"
  48.                 shift 2
  49.                 parameters="$@"
  50.                 # Systems with a separate /boot will not have
  51.                 # the path to the kernel in menu.lst.
  52.                 if [ "$partition" != "$bootpart" ]; then
  53.                     kernel="/boot$kernel"
  54.                 fi
  55.             ;;
  56.             initrd)
  57.                 initrd="$2"
  58.                 # Initrd same.
  59.                 if [ "$partition" != "$bootpart" ]; then
  60.                     initrd="/boot$initrd"
  61.                 fi
  62.             ;;
  63.             boot)
  64.                 entry_result
  65.             ;;
  66.         esac
  67.     done
  68.  
  69.     entry_result
  70. }
  71.  
  72. if [ -e "$mpoint/boot/grub/menu.lst" ]; then
  73.     debug "parsing menu.lst"
  74.     parse_grub_menu "$mpoint" "$partition" "$bootpart" < "$mpoint/boot/grub/menu.lst"
  75. elif [ -e "$mpoint/boot/grub/grub.conf" ]; then
  76.     debug "parsing grub.conf"
  77.     parse_grub_menu "$mpoint" "$partition" "$bootpart" < "$mpoint/boot/grub/grub.conf"
  78. fi
  79.  
  80. if [ "$found_item" = 0 ]; then
  81.     exit 1
  82. else
  83.     exit 0
  84. fi
  85.