home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / lib / partman / check.d / 10ext2_or_ext3_boot < prev    next >
Encoding:
Text File  |  2009-04-19  |  1.8 KB  |  74 lines

  1. #!/bin/sh
  2. # Check that the boot partition is the 1st (primary) partition and that
  3. # it is of type ext2 or ext3.
  4.  
  5. machine=$(grep "^Hardware" /proc/cpuinfo | sed 's/Hardware\s*:\s*//') || true
  6. case "$machine" in
  7.     "Buffalo Linkstation Pro/Live" | "Buffalo/Revogear Kurobox Pro")
  8.     ;;
  9.     "GLAN Tank")
  10.     ;;
  11.     "HP Media Vault mv2120")
  12.     ;;
  13.     *)
  14.         exit 0
  15.     ;;
  16. esac
  17.  
  18. . /lib/partman/lib/base.sh
  19.  
  20. for dev in $DEVICES/*; do
  21.     [ -d "$dev" ] || continue
  22.     cd $dev
  23.     open_dialog PARTITIONS
  24.     while { read_line num id size type fs path name; [ "$id" ]; }; do
  25.         [ "$fs" != free ] || continue
  26.         [ -f $id/method ] || continue
  27.         [ -f $id/acting_filesystem ] || continue
  28.         [ -f $id/mountpoint ] || continue
  29.         mountpoint=$(cat $id/mountpoint)
  30.         filesystem=$(cat $id/acting_filesystem)
  31.         if [ "$mountpoint" = / ]; then
  32.             root_fs=$filesystem
  33.             root_type=$type
  34.             root_path=$path
  35.         elif [ "$mountpoint" = /boot ]; then
  36.             boot_fs=$filesystem
  37.             boot_type=$type
  38.             boot_path=$path
  39.         fi
  40.     done
  41.     close_dialog
  42. done
  43.  
  44. # If no separate boot partition exists root acts as boot
  45. if [ -z "$boot_path" ]; then
  46.     boot_fs=$root_fs
  47.     boot_type=$root_type
  48.     boot_path=$root_path
  49. fi
  50.  
  51. # We need an ext2 or ext3 filesystem to boot
  52. if [ "$boot_fs" != ext2 ] && [ "$boot_fs" != ext3 ]; then
  53.     db_set partman-ext3/boot_not_ext2_or_ext3 true
  54.     db_input critical partman-ext3/boot_not_ext2_or_ext3 || true
  55.     db_go || true
  56.     db_get partman-ext3/boot_not_ext2_or_ext3
  57.     if [ "$RET" = true ]; then
  58.         exit 1
  59.     fi
  60. fi
  61.  
  62. # The boot file system has to be the first primary partition
  63. part_num=$(echo "$boot_path" | sed -e 's/.*[^0-9]\+//')
  64. if [ "$boot_type" != primary ] || [ "$part_num" -ne 1 ]; then
  65.     db_set partman/boot_not_first_partition true
  66.     db_input critical partman/boot_not_first_partition || true
  67.     db_go || true
  68.     db_get partman/boot_not_first_partition
  69.     if [ "$RET" = true ]; then
  70.         exit 1
  71.     fi
  72. fi
  73.  
  74.