Manage case of scan doesn't return any result

This commit is contained in:
Jeremy Gardais 2020-02-20 15:55:29 +01:00
parent 3258881a0f
commit 5ec0d0c8ee
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 48 additions and 44 deletions

View File

@ -87,7 +87,7 @@ if test -f /tmp/dscan; then rm -f -- /tmp/dscan; fi
smartctl --scan > /tmp/dscan
# TODO: Test if the file is not empty
if test -s /tmp/dscan; then
while IFS= read -r LINE; do
## Get device path
DISK=$(echo "${LINE}" | cut -d" " -f1)
@ -138,6 +138,10 @@ while IFS= read -r LINE; do
} >>/tmp/dres
done < /tmp/dscan > /tmp/dcheck
else
echo "1&red Error while scanning devices with smartctl" > /tmp/dcheck
fi
# Set the global color according to the highest alert
COLOR=$(< /tmp/dcheck awk '{print $1}' | sort | uniq | head -1 | cut -c3-)