diff --git a/smart.run.test.sh b/smart.run.test.sh index ce73c2c..be4145a 100755 --- a/smart.run.test.sh +++ b/smart.run.test.sh @@ -24,6 +24,21 @@ true > "${smart_device_list}" # Get the list of all available devices smartctl --scan >> "${smart_device_list}" +if test -s "${smart_device_list}"; then + while IFS= read -r LINE; do + ## Get device path + scanned_disk=$(echo "${LINE}" | cut -d" " -f1) + ## Try to determine the best type + scanned_type=$(echo "${LINE}" | cut -d" " -f3) + [ "${debug}" -eq "0" ] && printf "${c_magentab}%-6b${c_reset}\n" "DEBUG : smartctl scan ${scanned_disk} with type ${scanned_type}." + + done < "${smart_device_list}" + +# If the file is empty +else + printf "${c_redb}%-6b${c_reset}\n" "ERROR : The device list looks empty, check ${smart_device_list} file and \`smartctl --scan\` command." + exit 1 +fi # Remove temp_dir if debug is disable [ "${debug}" -eq "0" ] || rm -rf -- "${temp_dir}"