From d14839762a5e051b6429055918973901f1f4d272 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gardais=20J=C3=A9r=C3=A9my?= Date: Thu, 27 Feb 2020 15:50:51 +0100 Subject: [PATCH] Display help message --- smart.run.test.sh | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/smart.run.test.sh b/smart.run.test.sh index b5c7d75..990928b 100755 --- a/smart.run.test.sh +++ b/smart.run.test.sh @@ -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}"