home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / lib / partman / commit.d / 50format_ext3 < prev    next >
Encoding:
Text File  |  2006-08-30  |  2.8 KB  |  111 lines

  1. #!/bin/sh
  2.  
  3. . /lib/partman/definitions.sh
  4.  
  5. enable_swap
  6.  
  7. for dev in $DEVICES/*; do
  8.     [ -d "$dev" ] || continue
  9.     cd $dev
  10.     partitions=
  11.     open_dialog PARTITIONS
  12.     while { read_line num id size type fs path name; [ "$id" ]; }; do
  13.     [ "$fs" != free ] || continue
  14.         partitions="$partitions $id,$num"
  15.     done
  16.     close_dialog
  17.     
  18.     for part in $partitions; do
  19.         id=${part%,*}
  20.         num=${part#*,}
  21.     [ -f $id/method -a -f $id/format \
  22.         -a -f $id/acting_filesystem ] || continue
  23.     filesystem=$(cat $id/acting_filesystem)
  24.     case $filesystem in
  25.         ext3)
  26.         if 
  27.             [ -f $id/formatted -a $id/formatted -nt $id/method ] \
  28.             && [ ! -f $id/filesystem \
  29.                  -o $id/formatted -nt $id/filesystem ]
  30.         then
  31.             continue
  32.         fi
  33.         log "Try to create file system for $dev/$id"
  34.         if [ -f $id/mountpoint ]; then
  35.             template=partman-basicfilesystems/progress_formatting_mountable
  36.             db_subst $template MOUNT_POINT "$(cat $id/mountpoint)"
  37.         else
  38.             template=partman-basicfilesystems/progress_formatting
  39.         fi
  40.         open_dialog PARTITION_INFO $id
  41.         read_line x1 x2 x3 x4 x5 device x6
  42.         close_dialog
  43.  
  44.         RET=''
  45.         db_metaget  partman/filesystem_short/ext3 description || RET=''
  46.         [ "$RET" ] || RET=ext3
  47.         db_subst $template TYPE "$RET"
  48.         db_subst $template PARTITION "$num"
  49.         db_subst $template DEVICE $(humandev $(cat device))
  50.  
  51.         status=failed
  52.         if [ -x /sbin/tune2fs ] && ! [ -f $id/usage ]; then
  53.             name_progress_bar $template
  54.             open_dialog CREATE_FILE_SYSTEM $id ext2
  55.             read_line status
  56.             close_dialog
  57.             sync
  58.             if [ "$status" = OK ]; then
  59.             log-output -t partman --pass-stdout /sbin/tune2fs -j $device >/dev/null || status=failed
  60.             sync
  61.             fi
  62.         fi
  63.         if [ "$status" != OK ]; then
  64.             db_progress START 0 3 partman/text/formatting
  65.             db_progress INFO $template
  66.             db_progress SET 1
  67.             if [ -f $id/usage ]; then
  68.             usage="-T $(cat $id/usage)"
  69.             else
  70.             usage=''
  71.             fi
  72.             if
  73.             log-output -t partman --pass-stdout mkfs.ext3 $device $usage >/dev/null
  74.             then
  75.             sync
  76.             status=OK
  77.             else
  78.             status=failed
  79.             fi
  80.             db_progress STOP
  81.         fi
  82.         if [ "$status" = OK ]; then
  83.             if [ -f $id/label ]; then
  84.             label=$(cat $id/label|
  85.                 sed 's/\(................\).*/\1/g')
  86.             else
  87.             label=''
  88.             fi
  89.             if [ "$label" ]; then
  90.             log-output -t partman --pass-stdout tune2fs -L "$label" $device >/dev/null
  91.             fi
  92.             if [ -f $id/reserved_for_root ]; then
  93.             log-output -t partman --pass-stdout tune2fs -m $(cat $id/reserved_for_root) $device >/dev/null
  94.             fi
  95.         fi
  96.         if [ "$status" != OK ]; then
  97.             db_subst partman-ext3/create_failed PARTITION "$num"
  98.             db_subst partman-ext3/create_failed DEVICE $(humandev $(cat device))
  99.             db_input critical partman-ext3/create_failed || true
  100.             db_go || true
  101.             #disable_swap
  102.             exit 1
  103.         fi
  104.         >$id/formatted
  105.         ;;
  106.     esac
  107.     done
  108. done
  109.  
  110. #disable_swap
  111.