Create or empty previous files and fix redirection
This commit is contained in:
parent
5ec0d0c8ee
commit
b6c1913065
|
@ -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
|
||||
|
@ -135,11 +138,11 @@ if test -s /tmp/dscan; then
|
|||
echo "------------------------------------------------------------"
|
||||
echo ""
|
||||
echo ""
|
||||
} >>/tmp/dres
|
||||
done < /tmp/dscan > /tmp/dcheck
|
||||
} >> /tmp/dres
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue