Get disk path and type for each result

This commit is contained in:
Jeremy Gardais 2020-02-27 14:01:18 +01:00
parent ff57404836
commit 17734c77a1
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 15 additions and 0 deletions

View File

@ -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}"