home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / lib / partman / active_partition / 45basicfilesystems / choices next >
Encoding:
Text File  |  2006-08-30  |  3.8 KB  |  150 lines

  1. #!/bin/sh
  2.  
  3. . /usr/share/debconf/confmodule
  4.  
  5. set -e
  6.  
  7. dev=$1
  8. id=$2
  9. part=$dev/$id
  10.  
  11. cd $dev
  12.  
  13. [ -f $part/method -a -f $part/acting_filesystem ] || exit 0
  14.  
  15. method=$(cat $part/method)
  16. filesystem=$(cat $part/acting_filesystem)
  17.  
  18. case "$filesystem" in
  19.     ext2|fat16|fat32|ntfs)
  20.     :
  21.     ;;
  22.     *)
  23.     exit 0
  24.     ;;
  25. esac
  26.  
  27. choice_mountpoint () {
  28.     case "$filesystem" in
  29.     ext2|fat16|fat32|ntfs)
  30.         if [ -f $part/mountpoint ]; then
  31.         mp=$(cat $part/mountpoint)
  32.         else
  33.         db_metaget partman-basicfilesystems/text/no_mountpoint description
  34.         mp="$RET"
  35.         fi
  36.         db_metaget partman-basicfilesystems/text/specify_mountpoint description
  37.         RET=$(stralign -25 "$RET")
  38.         printf "mountpoint\t%s%s\n" "$RET" "$mp"
  39.         ;;
  40.     esac
  41. }
  42.  
  43. choice_options () {
  44.     if [ "$filesystem" = ntfs ]; then
  45.     # no mount options support yet (requires translations)
  46.     return
  47.     fi
  48.     db_metaget partman-basicfilesystems/text/options description
  49.     RET=$(stralign -25 "$RET")
  50.     printf "options\t%s%.45s\n" "$RET" "$(get_mountoptions $dev $id)"
  51. }
  52.  
  53. choice_format_swap () {
  54.     if 
  55.         [ "$method" = swap -a -f $part/detected_filesystem ] \
  56.         && [ "$(cat $part/detected_filesystem)" = linux-swap ]
  57.     then
  58.     db_metaget partman-basicfilesystems/text/format_swap description
  59.     description=$(stralign -25 "$RET")
  60.     if [ -f $part/format ]; then
  61.         db_metaget partman-basicfilesystems/text/yes description
  62.         printf "dont_format_swap\t%s%s\n" "$description" "${RET}"
  63.     else
  64.         db_metaget partman-basicfilesystems/text/no description
  65.         printf "format_swap\t%s%s\n" "$description" "${RET}"
  66.     fi
  67.     fi
  68. }
  69.  
  70. choice_label () {
  71.     # allow to set label only if the partition is to be formatted
  72.     [ -f $part/format ] || return 0
  73.     [ ! -f $part/formatted \
  74.       -o $part/formatted -ot $part/method \
  75.       -o $part/formatted -ot $part/filesystem ] || return 0
  76.     case "$filesystem" in
  77.     ext2)
  78.         if [ -f $part/label ]; then
  79.         label=$(cat $part/label)
  80.         else
  81.         db_metaget partman-basicfilesystems/text/none description
  82.         label=$RET
  83.         fi
  84.         db_metaget partman-basicfilesystems/text/specify_label description
  85.         RET=$(stralign -25 "$RET")
  86.         printf "label\t%s%s\n" "$RET" "$label"
  87.         ;;
  88.     _no_fat16|_no_fat32) # we dont have tools to set label of FAT file systems
  89.         if [ -f $part/label ]; then
  90.         label=$(cat $part/label)
  91.         else
  92.         db_metaget partman-basicfilesystems/text/none description
  93.         label=$RET
  94.         fi
  95.         db_metaget partman-basicfilesystems/text/specify_label description
  96.         RET=$(stralign -25 "$RET")
  97.         printf "label\t%s%s\n" "$RET" "$label"
  98.         ;;
  99.     esac
  100. }
  101.  
  102. choice_reserved () {
  103.     local reserved
  104.     [ "$filesystem" = ext2 ] || return 0
  105.     # allow to set reserved space only if the partition is to be formatted
  106.     [ -f $part/format ] || return 0
  107.     [ ! -f $part/formatted \
  108.       -o $part/formatted -ot $part/method \
  109.       -o $part/formatted -ot $part/filesystem ] || return 0
  110.     if [ -f $part/reserved_for_root ]; then
  111.     reserved=$(cat $part/reserved_for_root)
  112.     else
  113.     reserved=5
  114.     fi
  115.     db_metaget partman-basicfilesystems/text/reserved_for_root description
  116.     RET=$(stralign -25 "$RET")
  117.     printf "reserved_for_root\t%s%s\n" "$RET" "$reserved%"
  118. }
  119.  
  120. choice_usage () {
  121.     local usage
  122.     [ "$filesystem" = ext2 ] || return 0
  123.     # allow to set usage only if the partition is to be formatted
  124.     [ -f $part/format ] || return 0
  125.     [ ! -f $part/formatted \
  126.       -o $part/formatted -ot $part/method \
  127.       -o $part/formatted -ot $part/filesystem ] || return 0
  128.     if [ -f $part/usage ]; then
  129.     usage=$(cat $part/usage)
  130.     else
  131.     db_metaget partman-basicfilesystems/text/typical_usage description
  132.     usage=$RET
  133.     fi
  134.     db_metaget partman-basicfilesystems/text/usage description
  135.     RET=$(stralign -25 "$RET")
  136.     printf "usage\t%s%s\n" "$RET" "$usage"
  137. }
  138.  
  139. choice_mountpoint
  140.  
  141. choice_options
  142.  
  143. choice_format_swap
  144.  
  145. choice_label
  146.  
  147. choice_reserved
  148.  
  149. choice_usage
  150.