home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / lib / partman / active_partition / 45basicfilesystems / do_option < prev   
Encoding:
Text File  |  2006-08-30  |  3.7 KB  |  164 lines

  1. #!/bin/sh
  2.  
  3. . /lib/partman/definitions.sh
  4.  
  5. dev=$2
  6. id=$3
  7. part=$dev/$id
  8.  
  9. cd $dev
  10.  
  11. [ -f $part/method -a -f $part/acting_filesystem ] || exit 0
  12. filesystem=$(cat $part/acting_filesystem)
  13.  
  14. do_fatmountpoint () {
  15.     local noninteractive tpl
  16.     noninteractive=true
  17.     while true; do
  18.     if [ -f "$part/mountpoint" ]; then
  19.         old_mountpoint=$(cat $part/mountpoint)
  20.     else
  21.         old_mountpoint=/
  22.     fi
  23.     case "$filesystem" in
  24.         fat16|fat32|ntfs)
  25.         tpl=partman-basicfilesystems/fat_mountpoint
  26.         ;;
  27.         *)
  28.         tpl=partman-basicfilesystems/mountpoint
  29.         ;;
  30.     esac
  31.     db_set $tpl "$old_mountpoint"
  32.     db_input critical $tpl || $noninteractive
  33.     db_go || return 1
  34.     db_get $tpl
  35.  
  36.     case "$RET" in
  37.         Do?not?mount?it)
  38.                 rm -f $part/mountpoint
  39.         break
  40.         ;;
  41.         Enter?manually)
  42.         if do_mountpoint_manual; then break; fi
  43.         noninteractive="return 1"
  44.         ;;
  45.         *)
  46.         echo $RET >$part/mountpoint
  47.         break
  48.     esac
  49.     done
  50. }
  51.  
  52. do_mountpoint_manual () {
  53.     local noninteractive
  54.     noninteractive=true
  55.     while true; do
  56.     new_mountpoint=''
  57.     while [ ! "$new_mountpoint" ]; do
  58.         if [ -f "$part/mountpoint" ]; then
  59.         old_mountpoint=$(cat $part/mountpoint)
  60.         else
  61.         old_mountpoint=/
  62.         fi
  63.         db_set partman-basicfilesystems/mountpoint_manual "$old_mountpoint"
  64.         db_input critical partman-basicfilesystems/mountpoint_manual \
  65.         || $noninteractive
  66.         db_go || return 1
  67.         db_get partman-basicfilesystems/mountpoint_manual
  68.         
  69.         if expr "$RET" : '/[^ ]*$' >/dev/null; then
  70.         new_mountpoint=$RET
  71.         else
  72.         db_input high partman-basicfilesystems/bad_mountpoint || true
  73.         db_go || true
  74.         fi
  75.     done
  76.     echo $RET >$part/mountpoint
  77.     break
  78.     done
  79. }
  80.  
  81. case $1 in
  82.     mountpoint)
  83.     if [ "$filesystem" = fat16 -o "$filesystem" = fat32 -o "$filesystem" = ntfs ]; then
  84.         do_fatmountpoint
  85.     else
  86.         select_mountpoint $dev $id
  87.     fi
  88.     update_partition $dev $id
  89.     ;;
  90.     options)
  91.     if [ "$filesystem" = fat16 -o "$filesystem" = fat32 ]; then
  92.         select_mountoptions $dev $id partman-basicfilesystems/fatoptions
  93.     else
  94.         select_mountoptions $dev $id partman-basicfilesystems/options
  95.     fi
  96.     ;;
  97.     format_swap)
  98.     >$part/format
  99.     update_partition $dev $id
  100.     ;;
  101.     dont_format_swap)
  102.     if [ -f $part/format ]; then
  103.         rm $part/format
  104.         update_partition $dev $id
  105.     fi
  106.     ;;
  107.     label)
  108.     if [ -f $part/label ]; then
  109.         label=$(cat $part/label)
  110.     else
  111.         label=''
  112.     fi
  113.     db_set partman-basicfilesystems/choose_label "$label"
  114.     db_input critical partman-basicfilesystems/choose_label || true
  115.     db_go || exit 1
  116.     db_get partman-basicfilesystems/choose_label
  117.     if [ "$RET" ]; then
  118.         echo "$RET" >$part/label
  119.     else
  120.         rm -f $part/label
  121.     fi
  122.     db_reset partman-basicfilesystems/choose_label
  123.     ;;
  124.     reserved_for_root)
  125.     if [ -f $part/reserved_for_root ]; then
  126.         reserved=$(cat $part/reserved_for_root)
  127.     else
  128.         reserved=5
  129.     fi
  130.     db_set partman-basicfilesystems/specify_reserved "$reserved%"
  131.     db_input critical partman-basicfilesystems/specify_reserved || true
  132.     db_go || exit 1
  133.     db_get partman-basicfilesystems/specify_reserved
  134.     RET=`expr "$RET" : '\([0-9][0-9]\?\)\([,. %].*\)\?$'`
  135.     if [ "$RET" ]; then
  136.         echo "$RET" >$part/reserved_for_root
  137.     else
  138.         rm -f $part/reserved_for_root
  139.     fi
  140.     db_reset partman-basicfilesystems/specify_reserved
  141.     ;;
  142.     usage)
  143.     db_metaget partman-basicfilesystems/text/typical_usage description
  144.     typical_usage="$RET"
  145.     if [ -f $part/usage ]; then
  146.         usage=$(cat $part/usage)
  147.     else
  148.         usage="$typical_usage"
  149.     fi
  150.     db_subst partman-basicfilesystems/specify_usage CHOICES "$typical_usage, news, largefile, largefile4"
  151.     db_set partman-basicfilesystems/specify_usage "$usage"
  152.     db_input critical partman-basicfilesystems/specify_usage || true
  153.     db_go || exit 1
  154.     db_get partman-basicfilesystems/specify_usage
  155.     if [ "$RET" != "$typical_usage" ]; then
  156.         echo "$RET" >$part/usage
  157.     else
  158.         rm -f $part/usage
  159.     fi
  160.     ;;
  161. esac
  162.  
  163. exit 0
  164.