From 17734c77a11fa6c555273c394af0b6996ab10467 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gardais=20J=C3=A9r=C3=A9my?= Date: Thu, 27 Feb 2020 14:01:18 +0100 Subject: [PATCH] Get disk path and type for each result --- smart.run.test.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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}"