home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / etc / bash_completion.d / mdadm < prev    next >
Encoding:
Text File  |  2010-11-16  |  4.5 KB  |  163 lines

  1. # bash completion for mdadm
  2.  
  3. have mdadm &&
  4. {
  5. _mdadm_raid_level()
  6. {
  7.     local mode
  8.  
  9.     for (( i=1; i < COMP_CWORD; i++ )); do
  10.         case ${COMP_WORDS[i]} in
  11.             -C|--create)
  12.                 mode=create
  13.                 break
  14.                 ;;
  15.             -B|--build)
  16.                 mode=build
  17.                 break
  18.                 ;;
  19.         esac
  20.     done
  21.  
  22.     case $mode in
  23.         create)
  24.             COMPREPLY=( $( compgen -W 'linear raid0 0 stripe raid1 1 mirror \
  25.                 raid4 4 raid5 5 raid6 6 raid10 10 multipath mp faulty' \
  26.                 -- "$cur" ) )
  27.             ;;
  28.         build)
  29.             COMPREPLY=( $( compgen -W 'linear stripe raid0 0 raid1 multipath \
  30.                 mp faulty' -- "$cur" ) )
  31.             ;;
  32.     esac
  33. }
  34.  
  35. _mdadm_raid_layout()
  36. {
  37.     local level
  38.     for (( i=1; i < COMP_CWORD; i++ )); do
  39.         if [[ "${COMP_WORDS[i]}" == -@(l|-level) ]]; then
  40.             level=${COMP_WORDS[i+1]}
  41.             break
  42.         fi
  43.     done
  44.  
  45.     case $level in
  46.         raid5)
  47.             COMPREPLY=( $( compgen -W 'left-asymmetric left-symmetric \
  48.                 right-asymmetric right-symmetric la ra ls rs' -- "$cur" ) )
  49.             ;;
  50.         raid10)
  51.             COMPREPLY=( $( compgen -W 'n o p' -- "$cur" ) )
  52.             ;;
  53.         faulty)
  54.             COMPREPLY=( $( compgen -W 'write-transient wt read-transient rt \
  55.                 write-persistent wp read-persistent rp write-all read-fixable \
  56.                 rf clear flush none' -- $cur ) )
  57.             ;;
  58.     esac
  59. }
  60.  
  61. _mdadm_auto_flag()
  62. {
  63.     COMPREPLY=( $( compgen -W 'no yes md mdp part p' -- "$cur" ) )
  64. }
  65.  
  66. _mdadm_update_flag()
  67. {
  68.     COMPREPLY=( $( compgen -W 'sparc2.2 summaries uuid name homehost resync \
  69.         byteorder super-minor' -- "$cur" ) )
  70. }
  71.  
  72.  
  73. _mdadm()
  74. {
  75.     local cur prev mode options split=false
  76.  
  77.     COMPREPLY=()
  78.     _get_comp_words_by_ref cur prev
  79.  
  80.     _split_longopt && split=true
  81.  
  82.     case $prev in
  83.         -c|--config|-b|--bitmap|--backup-file)
  84.             _filedir
  85.             return 0
  86.             ;;
  87.         -l|--level)
  88.             _mdadm_raid_level
  89.             return 0
  90.             ;;
  91.         -p|--layout|--parity)
  92.             _mdadm_raid_layout
  93.             return 0
  94.             ;;
  95.         -a|--auto)
  96.             _mdadm_auto_flag
  97.             return 0
  98.             ;;
  99.         -U|--update)
  100.             _mdadm_update_flag
  101.             return 0
  102.             ;;
  103.     esac
  104.  
  105.     $split && return 0
  106.  
  107.     options='--help --help-options --version --verbose --quiet \
  108.         --brief --force --config --scan --metadata --homehost'
  109.  
  110.     if [[ "$cur" == -* ]]; then
  111.         if [[ $COMP_CWORD -eq 1 ]] ; then
  112.             COMPREPLY=( $( compgen -W "$options --assemble --build \
  113.                 --create --monitor --grow" -- "$cur" ) )
  114.         else
  115.             case ${COMP_WORDS[COMP_CWORD-1]} in
  116.                 -A|--assemble)
  117.                     COMPREPLY=( $( compgen -W "$options --uuid \
  118.                         --super-minor --name --force --run \
  119.                         --no-degraded --auto --bitmap --backup-file \
  120.                         --update --auto-update-homehost" -- "$cur" ) )
  121.                     ;;
  122.                 -B|-C|-G|--build|--create|--grow)
  123.                     COMPREPLY=( $( compgen -W "$options --raid-devices \
  124.                         --spare-devices --size --chunk --rounding \
  125.                         --level --layout --parity --bitmap \
  126.                         --bitmap-chunk --write-mostly --write-behind \
  127.                         --assume-clean --backup-file --name --run \
  128.                         --force --auto" -- "$cur" ) )
  129.                     ;;
  130.                 -F|--follow|--monitor)
  131.                     COMPREPLY=( $( compgen -W "$options --mail --program \
  132.                         --alert --syslog --delay --daemonise \
  133.                         --pid-file --oneshot --test" -- "$cur" ) )
  134.  
  135.                     ;;
  136.                 /dev/*|--add|--fail|--remove)
  137.                     COMPREPLY=( $( compgen -W "$options --add --re-add \
  138.                         --remove --fail --set-faulty" -- "$cur" ) )
  139.                     ;;
  140.                 *)
  141.                     COMPREPLY=( $( compgen -W "$options --query --detail \
  142.                         --examine --sparc2.2 --examine-bitmap --run \
  143.                         --stop --readonly --readwrite \
  144.                         --zero-superblock --test" -- "$cur" ) )
  145.                     ;;
  146.             esac
  147.         fi
  148.     else
  149.         cur=${cur:=/dev/}
  150.         _filedir
  151.     fi
  152. }
  153. complete -F _mdadm mdadm
  154. }
  155.  
  156. # Local variables:
  157. # mode: shell-script
  158. # sh-basic-offset: 4
  159. # sh-indent-comment: t
  160. # indent-tabs-mode: nil
  161. # End:
  162. # ex: ts=4 sw=4 et filetype=sh
  163.