Create or empty previous files and fix redirection

This commit is contained in:
Jeremy Gardais 2020-02-20 16:02:05 +01:00
parent 5ec0d0c8ee
commit b6c1913065
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 11 additions and 8 deletions

View File

@ -27,10 +27,11 @@ is_disk_support_smart() {
[ "${debug}" -eq "0" ] && printf "${c_magentab}%-6b${c_reset}\n" "DEBUG: is_disk_support_smart func check if SMART is supported on: ${_disk}."
if test -f "${_smarctl_support_result}"; then rm -f -- "${_smarctl_support_result}"; fi
## Create or empty previous file
true > "${_smarctl_support_result}"
## Grep only "support" lines from disk's informations
smartctl -d "${_type}" -i -- "${_disk}" | grep -E "^SMART support is:" -- > "${_smarctl_support_result}"
smartctl -d "${_type}" -i -- "${_disk}" | grep -E "^SMART support is:" -- >> "${_smarctl_support_result}"
## If the file is not empty
if test -s "${_smarctl_support_result}"; then
@ -80,11 +81,13 @@ choose_correct_type() {
}
## }}}
if test -f /tmp/dres; then rm -f -- /tmp/dres; fi
if test -f /tmp/dscan; then rm -f -- /tmp/dscan; fi
# Create or empty previous files
true > /tmp/dres
true > /tmp/dcheck
true > /tmp/dscan
# Get the list of all available devices
smartctl --scan > /tmp/dscan
smartctl --scan >> /tmp/dscan
# TODO: Test if the file is not empty
if test -s /tmp/dscan; then
@ -136,10 +139,10 @@ if test -s /tmp/dscan; then
echo ""
echo ""
} >> /tmp/dres
done < /tmp/dscan > /tmp/dcheck
done < /tmp/dscan >> /tmp/dcheck
else
echo "1&red Error while scanning devices with smartctl" > /tmp/dcheck
echo "1&red Error while scanning devices with smartctl" >> /tmp/dcheck
fi
# Set the global color according to the highest alert