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

  1. #!/bin/sh
  2.  
  3. . /lib/partman/definitions.sh
  4.  
  5. for dev in $DEVICES/*; do
  6.     [ -d "$dev" ] || continue
  7.     cd $dev
  8.     partitions=
  9.     open_dialog PARTITIONS
  10.     while { read_line num id size type fs path name; [ "$id" ]; }; do
  11.     [ "$fs" != free ] || continue
  12.         partitions="$partitions $id,$num"
  13.     done
  14.     close_dialog
  15.     
  16.     for part in $partitions; do
  17.         id=${part%,*}
  18.         num=${part#*,}
  19.     [ -f $id/method -a -f $id/format ] || continue
  20.     method=$(cat $id/method)
  21.     if [ "$method" = swap ]; then
  22.         if 
  23.         [ -f $id/formatted -a $id/formatted -nt $id/method ]
  24.         then
  25.         continue
  26.         fi
  27.         log "Try to format swap space in $dev/$id"
  28.         template=partman-basicfilesystems/progress_swap_formatting
  29.         open_dialog PARTITION_INFO $id
  30.         read_line x1 x2 x3 x4 x5 device x6
  31.         close_dialog
  32.         db_subst $template PARTITION "$num"
  33.         db_subst $template DEVICE $(humandev $(cat device))
  34.         name_progress_bar $template
  35.         open_dialog CREATE_FILE_SYSTEM $id linux-swap
  36.         read_line status
  37.         close_dialog
  38.         sync
  39.         if [ "$status" != OK ]; then
  40.         db_progress START 0 3 partman/text/formatting
  41.         db_progress INFO $template
  42.         db_progress SET 1
  43.         if
  44.             log-output -t partman --pass-stdout mkswap $device >/dev/null
  45.         then
  46.             sync
  47.             status=OK
  48.         else
  49.             status=failed
  50.         fi
  51.         db_progress STOP
  52.         fi
  53.         
  54.         if [ "$status" != OK ]; then
  55.         db_subst partman-basicfilesystems/create_swap_failed TYPE linux-swap
  56.         db_subst partman-basicfilesystems/create_swap_failed PARTITION "$num"
  57.         db_subst partman-basicfilesystems/create_swap_failed DEVICE $(humandev $(cat device))
  58.         db_input critical partman-basicfilesystems/create_swap_failed || true
  59.         db_go || true
  60.         exit 1
  61.         fi
  62.         >$id/formatted
  63.     fi
  64.     done
  65. done
  66.