Display help message

This commit is contained in:
Jeremy Gardais 2020-02-27 15:50:51 +01:00
parent e7300d63f1
commit d14839762a
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 41 additions and 0 deletions

View File

@ -18,6 +18,45 @@ smart_device_list="${temp_dir}/smart.device.list"
# ]]]
# Functions
## Print help message [[[
print_help_message() {
cat << HELP
usage: $(basename "${0}") [TEST TYPE]
Try to run a SMART test on all compatible devices.
positional arguments:
TEST TYPE Test type to run on all devices. Can be:
short (default) - runs SMART Short Self Test (usually under ten minutes)
long - runs SMART Extended Self Test (tens of minutes to
several hours).
EXAMPLE:
- Run a short test
$(basename "${0}") short
HELP
}
## ]]]
## Check the arguments [[[
check_arguments() {
_nb_arg="${#}"
_all_args="${*}"
[ "${debug}" -eq "0" ] && printf "${c_magentab}%-6b${c_reset}\n" "DEBUG: check_arguments func ${_nb_arg} argument(s) to manage. List:\n ${_all_args}"
## If help is needed [[[
if printf -- '%s' "${_all_args}" | grep -q -E -- "-h|--help|help"; then
print_help_message
exit 0
fi
## ]]]
}
## ]]]
## Test if a disk really support SMART [[[
## Smartctl can give an health status even without a full support
## of SMART for some type (eg. scsi or megaraid).
@ -80,6 +119,8 @@ choose_correct_type() {
}
## ]]]
check_arguments "${@}"
# Create files
true > "${smart_device_list}"