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 / commit.d / 01unmount_busy next >
Encoding:
Text File  |  2007-04-12  |  1.6 KB  |  79 lines

  1. #! /bin/sh
  2.  
  3. . /lib/partman/definitions.sh
  4.  
  5. if [ -f /etc/mtab ]; then
  6.     MTAB=/etc/mtab
  7. else
  8.     MTAB=/proc/mounts
  9. fi
  10.  
  11. busy_partitions=
  12.  
  13. for dev in $DEVICES/*; do
  14.     [ -d "$dev" ] || continue
  15.     cd $dev
  16.  
  17.     partitions=
  18.     found_mounted=false
  19.     open_dialog PARTITIONS
  20.     while { read_line num id size type fs path name; [ "$id" ]; }; do
  21.     [ "$fs" != free ] || continue
  22.     partitions="$partitions $id,$path"
  23.     if [ -f "$id/mountpoint" ]; then
  24.         mp="$(cat "$id/mountpoint")"
  25.         case $mp in
  26.         /media/*)
  27.             ;;
  28.         *)
  29.             found_mounted=:
  30.             ;;
  31.         esac
  32.     fi
  33.     done
  34.     close_dialog
  35.  
  36.     if ! $found_mounted; then
  37.     open_dialog IS_CHANGED
  38.     read_line changed
  39.     close_dialog
  40.     [ "$changed" = yes ] || continue
  41.     fi
  42.  
  43.     for part in $partitions; do
  44.     id="${part%,*}"
  45.     path="${part#*,}"
  46.     open_dialog IS_BUSY "$id"
  47.     read_line busy
  48.     close_dialog
  49.     [ "$busy" = yes ] || continue
  50.     busy_partitions="$busy_partitions $path"
  51.     done
  52. done
  53.  
  54. [ "$busy_partitions" ] || exit 0
  55.  
  56. noninteractive=:
  57. while :; do
  58.     failed_mountpoints=
  59.     for part in $busy_partitions; do
  60.     for mp in $(grep "^$part " "$MTAB" | cut -d' ' -f2); do
  61.         umount $mp || failed_mountpoints="${failed_mountpoints:+$failed_mountpoints }$mp"
  62.     done
  63.     done
  64.  
  65.     if [ -z "$failed_mountpoints" ]; then
  66.     break
  67.     fi
  68.  
  69.     db_reset ubiquity/partman-failed-unmount
  70.     db_subst ubiquity/partman-failed-unmount MOUNTED "$failed_mountpoints"
  71.     db_input critical ubiquity/partman-failed-unmount || $noninteractive
  72.     db_go || exit 1
  73.     db_get ubiquity/partman-failed-unmount
  74.     [ "$RET" = true ] || exit 1
  75.     noninteractive='exit 1'
  76. done
  77.  
  78. exit 0
  79.