2009-04-18 13:31:59 +03:00
|
|
|
# bash completion for smartctl(8)
|
2009-02-04 21:23:49 +01:00
|
|
|
|
2011-04-05 00:35:51 +03:00
|
|
|
have smartctl || return
|
|
|
|
|
2009-02-04 21:23:49 +01:00
|
|
|
_smartctl_quietmode()
|
|
|
|
{
|
2009-10-18 21:54:54 +03:00
|
|
|
COMPREPLY=( $( compgen -W 'errorsonly silent noserial' -- "$cur" ) )
|
2009-02-04 21:23:49 +01:00
|
|
|
}
|
|
|
|
_smartctl_device()
|
|
|
|
{
|
2011-02-18 22:09:05 +02:00
|
|
|
case $cur in
|
|
|
|
areca*|3ware*|megaraid*|cciss*)
|
2011-04-25 23:44:08 +03:00
|
|
|
COMPREPLY+=( ${cur%%,*},{0..31} )
|
2011-02-18 22:09:05 +02:00
|
|
|
COMPREPLY=( $( compgen -W '"${COMPREPLY[@]}"' -- "$cur" ) )
|
|
|
|
;;
|
|
|
|
hpt*)
|
2011-04-25 23:44:08 +03:00
|
|
|
COMPREPLY+=( hpt,{1..4}/{1..8} hpt,{1..4}/{1..8}/{1..5} )
|
2011-02-18 22:09:05 +02:00
|
|
|
COMPREPLY=( $( compgen -W '"${COMPREPLY[@]}"' -- "$cur" ) )
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
COMPREPLY=( $( compgen -W "ata scsi sat usbcypress usbjmicron
|
|
|
|
usbsunplus marvell areca 3ware hpt megaraid cciss auto test" \
|
|
|
|
-- "$cur" ) )
|
|
|
|
case "${COMPREPLY[@]}" in
|
|
|
|
areca|3ware|hpt|megaraid|cciss)
|
2011-04-21 12:35:24 +03:00
|
|
|
compopt -o nospace
|
2011-02-18 22:09:05 +02:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
esac
|
2009-02-04 21:23:49 +01:00
|
|
|
}
|
|
|
|
_smartctl_tolerance()
|
|
|
|
{
|
2009-10-18 21:54:54 +03:00
|
|
|
COMPREPLY=( $( compgen -W 'normal conservative permissive \
|
|
|
|
verypermissive' -- "$cur" ) )
|
2009-02-04 21:23:49 +01:00
|
|
|
}
|
|
|
|
_smartctl_badsum()
|
|
|
|
{
|
2009-10-18 21:54:54 +03:00
|
|
|
COMPREPLY=( $( compgen -W 'warn exit ignore' -- "$cur" ) )
|
2009-02-04 21:23:49 +01:00
|
|
|
}
|
|
|
|
_smartctl_report()
|
|
|
|
{
|
2009-10-18 21:54:54 +03:00
|
|
|
COMPREPLY=( $( compgen -W 'ioctl ataioctl scsiioctl' -- "$cur" ) )
|
2009-02-04 21:23:49 +01:00
|
|
|
}
|
2009-04-18 13:16:58 +03:00
|
|
|
_smartctl_powermode()
|
|
|
|
{
|
2009-10-18 21:54:54 +03:00
|
|
|
COMPREPLY=( $( compgen -W 'never sleep standby idle' -- "$cur" ) )
|
2009-04-18 13:16:58 +03:00
|
|
|
}
|
2009-02-04 21:23:49 +01:00
|
|
|
_smartctl_feature()
|
|
|
|
{
|
2009-10-18 21:54:54 +03:00
|
|
|
COMPREPLY=( $( compgen -W 'on off' -- "$cur" ) )
|
2009-02-04 21:23:49 +01:00
|
|
|
}
|
|
|
|
_smartctl_log()
|
|
|
|
{
|
2011-02-18 22:09:05 +02:00
|
|
|
COMPREPLY=( $( compgen -W 'error selftest selective directory background
|
|
|
|
sasphy sasphy,reset sataphy sataphy,reset scttemp scttempsts
|
|
|
|
scttemphist scterc gplog smartlog xerror xselftest' -- "$cur" ) )
|
2009-02-04 21:23:49 +01:00
|
|
|
}
|
|
|
|
_smartctl_vendorattribute()
|
|
|
|
{
|
2009-10-18 21:54:54 +03:00
|
|
|
COMPREPLY=( $( compgen -W 'help 9,minutes 9,seconds 9,halfminutes \
|
|
|
|
9,temp 192,emergencyretractcyclect 193,loadunload \
|
|
|
|
194,10xCelsius 194,unknown 198,offlinescanuncsectorct \
|
|
|
|
200,writeerrorcount 201,detectedtacount 220,temp' -- "$cur" ) )
|
2009-02-04 21:23:49 +01:00
|
|
|
}
|
|
|
|
_smartctl_firmwarebug()
|
|
|
|
{
|
2009-10-18 21:54:54 +03:00
|
|
|
COMPREPLY=( $( compgen -W 'none samsung samsung2 samsung3 swapid' \
|
2009-10-04 19:42:50 +02:00
|
|
|
-- "$cur" ) )
|
2009-02-04 21:23:49 +01:00
|
|
|
}
|
|
|
|
_smartctl_presets()
|
|
|
|
{
|
2009-10-18 21:54:54 +03:00
|
|
|
COMPREPLY=( $( compgen -W 'use ignore show showall' -- "$cur" ) )
|
2009-02-04 21:23:49 +01:00
|
|
|
}
|
|
|
|
_smartctl_test()
|
|
|
|
{
|
2011-02-18 22:09:05 +02:00
|
|
|
[[ $cur == @(pending|scttempint|vendor), ]] && return 0
|
|
|
|
COMPREPLY=( $( compgen -W 'offline short long conveyance select,
|
|
|
|
select,redo select,next afterselect,on afterselect,off pending,
|
|
|
|
scttempint, vendor,' -- "$cur" ) )
|
2011-04-27 15:46:27 +03:00
|
|
|
[[ $COMPREPLY == *, ]] && compopt -o nospace
|
2011-02-18 22:09:05 +02:00
|
|
|
}
|
|
|
|
_smartctl_drivedb()
|
|
|
|
{
|
|
|
|
local prefix=
|
|
|
|
if [[ $cur == +* ]] ; then
|
|
|
|
prefix=+
|
|
|
|
cur="${cur#+}"
|
|
|
|
fi
|
|
|
|
_filedir h
|
|
|
|
[[ -n $prefix ]] && COMPREPLY=( "${COMPREPLY[@]/#/$prefix}" )
|
2009-02-04 21:23:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
_smartctl()
|
|
|
|
{
|
2011-04-21 11:04:51 +03:00
|
|
|
local cur prev words cword
|
2011-04-25 00:09:50 +03:00
|
|
|
_init_completion -n = || return
|
2009-02-04 21:23:49 +01:00
|
|
|
|
2011-04-21 11:04:51 +03:00
|
|
|
local split=false
|
2009-10-18 21:54:54 +03:00
|
|
|
_split_longopt && split=true
|
2009-04-18 13:15:07 +03:00
|
|
|
|
2009-12-30 00:39:59 +01:00
|
|
|
case $prev in
|
2009-10-18 21:54:54 +03:00
|
|
|
-q|--quietmode)
|
|
|
|
_smartctl_quietmode
|
|
|
|
;;
|
|
|
|
-d|--device)
|
|
|
|
_smartctl_device
|
|
|
|
return 0
|
|
|
|
;;
|
2011-04-27 15:47:56 +03:00
|
|
|
-T|--tolerance)
|
2009-10-18 21:54:54 +03:00
|
|
|
_smartctl_tolerance
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
-b|--badsum)
|
|
|
|
_smartctl_badsum
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
-r|--report)
|
|
|
|
_smartctl_report
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
-n|--nocheck)
|
|
|
|
_smartctl_powermode
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
-s|--smart|-o|--offlineauto|-S|--saveauto)
|
|
|
|
_smartctl_feature
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
-l|--log)
|
|
|
|
_smartctl_log
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
-v|--vendorattribute)
|
|
|
|
_smartctl_vendorattribute
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
-F|--firmwarebug)
|
|
|
|
_smartctl_firmwarebug
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
-P|--presets)
|
|
|
|
_smartctl_presets
|
|
|
|
return 0
|
|
|
|
;;
|
2011-02-18 22:09:05 +02:00
|
|
|
-B|--drivedb)
|
|
|
|
_smartctl_drivedb
|
|
|
|
return 0
|
|
|
|
;;
|
2009-10-18 21:54:54 +03:00
|
|
|
-t|--test)
|
|
|
|
_smartctl_test
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
esac
|
2009-02-04 21:23:49 +01:00
|
|
|
|
2009-10-18 21:54:54 +03:00
|
|
|
$split && return 0
|
2009-02-04 21:23:49 +01:00
|
|
|
|
2009-10-18 21:54:54 +03:00
|
|
|
if [[ "$cur" == -* ]]; then
|
2011-02-18 22:09:05 +02:00
|
|
|
COMPREPLY=( $( compgen -W '--help --version --info --all --xall
|
|
|
|
--scan --scan-open --quietmode --device --tolerance --badsum
|
|
|
|
--report --nocheck --smart --offlineauto --saveauto --health
|
|
|
|
--capabilities --attributes --log --vendorattribute --firmwarebug
|
|
|
|
--presets --drivedb --test --captive --abort' -- "$cur" ) )
|
2009-10-18 21:54:54 +03:00
|
|
|
else
|
|
|
|
cur=${cur:=/dev/}
|
|
|
|
_filedir
|
|
|
|
fi
|
2011-04-04 22:14:39 +03:00
|
|
|
} &&
|
2009-02-04 21:23:49 +01:00
|
|
|
complete -F _smartctl smartctl
|
2009-10-01 20:54:51 +03:00
|
|
|
|
|
|
|
# Local variables:
|
|
|
|
# mode: shell-script
|
2009-10-04 19:42:50 +02:00
|
|
|
# sh-basic-offset: 4
|
2009-10-01 20:54:51 +03:00
|
|
|
# sh-indent-comment: t
|
2009-10-04 19:42:50 +02:00
|
|
|
# indent-tabs-mode: nil
|
2009-10-01 20:54:51 +03:00
|
|
|
# End:
|
2009-10-04 19:42:50 +02:00
|
|
|
# ex: ts=4 sw=4 et filetype=sh
|