Set clear status if SMART is not supported

This commit is contained in:
Jeremy Gardais 2020-02-20 11:18:18 +01:00
parent 26d6b06c86
commit 3b016ae797
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 13 additions and 5 deletions

View File

@ -3,7 +3,7 @@
# NOTE: Must be run as root, so you probably need to setup sudo for this. # NOTE: Must be run as root, so you probably need to setup sudo for this.
# Vars {{{ # Vars {{{
debug="0" debug="1"
## Colors {{{ ## Colors {{{
c_redb='\033[1;31m' c_redb='\033[1;31m'
@ -50,7 +50,6 @@ is_disk_support_smart() {
} }
## }}} ## }}}
if test -f /tmp/dres; then rm -f /tmp/dres; fi if test -f /tmp/dres; then rm -f /tmp/dres; fi
if test -f /tmp/dscan; then rm -f /tmp/dscan; fi if test -f /tmp/dscan; then rm -f /tmp/dscan; fi
@ -64,9 +63,18 @@ while IFS= read -r LINE; do
is_disk_support_smart "${DISK}" "${TYPE}" is_disk_support_smart "${DISK}" "${TYPE}"
## Get SMART Health Status and return code ## If SMART is supported on the disk
if [ -z "${smart_support_msg}" ]; then
[ "${debug}" -eq "0" ] && printf "${c_magentab}%-6b${c_reset}\n" "DEBUG: SMART seems fully supported, proceed normally."
### Get SMART Health Status and return code
DRES=$(/usr/sbin/smartctl -H -d "${TYPE}" -n standby "${DISK}") DRES=$(/usr/sbin/smartctl -H -d "${TYPE}" -n standby "${DISK}")
DCODE=$? DCODE=$?
else
[ "${debug}" -eq "0" ] && printf "${c_magentab}%-6b${c_reset}\n" "DEBUG: SMART is not fully supported, get ."
DRES=$(printf '%s' "${smart_support_msg}")
DCODE="2"
fi
DSTBY=$(( DCODE & 2 )) DSTBY=$(( DCODE & 2 ))
DFAIL=$(( DCODE & 8 )) DFAIL=$(( DCODE & 8 ))
DWARN=$(( DCODE & 32 )) DWARN=$(( DCODE & 32 ))