home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / lib / partman / auto.d / 10initial_auto
Encoding:
Text File  |  2007-04-12  |  2.8 KB  |  123 lines

  1. #!/bin/sh
  2.  
  3. . /usr/share/debconf/confmodule
  4. . /lib/partman/definitions.sh
  5. . /lib/partman/auto-shared.sh
  6.  
  7. dev_to_partman () {
  8.     local dev_name="$1"
  9.     
  10.     local mapped_dev_name="$(mapdevfs $dev_name)"
  11.     if [ -n "$mapped_dev_name" ]; then
  12.         dev_name="$mapped_dev_name"
  13.     fi
  14.  
  15.     for dev in $DEVICES/*; do
  16.         # mapdevfs both to allow for different ways to refer to the
  17.         # same device using devfs, and to allow user input in
  18.         # non-devfs form
  19.         if [ "$(mapdevfs $(cat $dev/device))" = "$dev_name" ]; then
  20.             echo $dev
  21.         fi
  22.     done
  23. }
  24.  
  25. # Do not run on S/390
  26. if [ "$(udpkg --print-architecture)" = s390 ]; then
  27.     exit 0
  28. fi
  29.  
  30. # Only run the first time
  31. if [ -f /var/lib/partman/initial_auto ]; then
  32.     exit 0
  33. fi
  34. [ -d /var/lib/partman ] || mkdir /var/lib/partman
  35. touch /var/lib/partman/initial_auto
  36.  
  37. # See if any autopartition method has been set
  38. method=""
  39. if db_get partman-auto/method && [ "$RET" ]; then
  40.     method="$RET"
  41. fi
  42.  
  43. # See if any autopartition disks have been set
  44. disks=""
  45. if db_get partman-auto/disk && [ "$RET" ]; then
  46.     disks="$RET"
  47. fi
  48.  
  49. # If there's only one disk, then preseeding partman-auto/disk is unnecessary
  50. if [ "$method" ] && [ -z "$disks" ]; then
  51.     DEVS="$(get_auto_disks)"
  52.     if [ "$(echo "$DEVS" | wc -l)" -eq 1 ]; then
  53.         disks="$(cat "${DEVS%$TAB*}"/device)"
  54.     fi
  55. fi
  56.  
  57. # If both are set, let's try to do a completely automatic partitioning
  58. if [ "$method" ] && [ "$disks" ]; then
  59.     # The code for the methods could be merged, but in the future non-regular
  60.     # methods may support multiple disks
  61.     case "$method" in
  62.         regular)
  63.             for disk in $disks; do
  64.                 id=$(dev_to_partman "$disk") || true
  65.                 if [ -n "$id" ]; then
  66.                     autopartition "$id"
  67.                     exit 0
  68.                 fi
  69.             done
  70.             exit 1
  71.             ;;
  72.         lvm)
  73.             search-path autopartition-lvm || exit 1
  74.             for disk in $disks; do
  75.                 id=$(dev_to_partman "$disk") || true
  76.                 if [ -n "$id" ]; then
  77.                     autopartition-lvm "$id"
  78.                     exit 0
  79.                 fi
  80.             done
  81.             exit 1
  82.             ;;
  83.         crypto)
  84.             search-path autopartition-crypto || exit 1
  85.             for disk in $disks; do
  86.                 id=$(dev_to_partman "$disk") || true
  87.                 if [ -n "$id" ]; then
  88.                     autopartition-crypto "$id"
  89.                     exit 0
  90.                 fi
  91.             done
  92.             exit 1
  93.             ;;
  94.         raid)
  95.             # Partition all the disks given ready for
  96.             # partman-auto-raid
  97.             for disk in $disks; do
  98.                 id=$(dev_to_partman "$disk") || true
  99.                 if [ -n "$id" ]; then
  100.                     autopartition "$id"
  101.                 fi
  102.             done
  103.             exit 0
  104.             ;;
  105.         *)
  106.             logger -t partman-auto "Unsupported method '$method'"
  107.             exit 1
  108.             ;;
  109.     esac
  110. fi
  111.  
  112. echo "partman-auto/init_automatically_partition" > /lib/partman/automatically_partition/question
  113. code=99 # signals a retry
  114. while [ $code = 99 ]; do
  115.     ask_user /lib/partman/automatically_partition 
  116.     code=$?
  117. done
  118. if [ $code -lt 100 ]; then
  119.     rm -f /var/lib/partman/initial_auto # try again
  120. fi
  121. echo "partman-auto/automatically_partition" > /lib/partman/automatically_partition/question
  122. exit $code
  123.