Skip to content

Commit

Permalink
fix shellcheck issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Klintrup committed Dec 3, 2023
1 parent c2d5e3b commit 30a6045
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions check_smartarray.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,29 @@
# Written by: Søren Klintrup <github at klintrup.dk>
# Get your copy from: https://github.com/Klintrup/check_smartarray/

unset ERRORSTRING
unset OKSTRING
unset ERR

PATH="/sbin:/bin:/usr/sbin:/usr/bin"
if [ -x "/sbin/camcontrol" ]
then
DEVICES="$(camcontrol devlist|egrep "(HP|COMPAQ) RAID"|sed -Ee 's/.*(pass[0-9]{1,3}).*/\1/')"
DEVICES="$(camcontrol devlist|grep -Ee "(HP|COMPAQ) RAID"|sed -Ee 's/.*(pass[0-9]{1,3}).*/\1/')"
else
ERRORSTRING="camcontrol binary does not exist on system"
ERR=3
fi

unset ERRORSTRING
unset OKSTRING
unset ERR

for DEVICE in ${DEVICES}
do
DEVICENAME="$(camcontrol devlist|grep ${DEVICE}|sed -Ee 's/.*(da[0-9]{1,3}).*/\1/')"
DEVICESTRING="$(camcontrol inquiry ${DEVICE} -D|sed -n -e 's/^[^<]*<\([^>]*\)>.*$/\1/p')"
if [ "$(echo ${DEVICESTRING}|tr [:upper:] [:lower:]|sed -Ee 's/.*(rea|int|exp|rec|fai|ok).*/\1/')" = "" ]
if [ "$(echo ${DEVICESTRING}|tr '[:upper:]' '[:lower:]'|sed -Ee 's/.*(rea|int|exp|rec|fai|ok).*/\1/')" = "" ]
then
ERRORSTRING="${ERRORSTRING} / ${DEVICENAME}: unknown state"
if ! [ "${ERR}" = 2 ];then ERR=3;fi
else
case $(echo ${DEVICESTRING}|tr [:upper:] [:lower:]|sed -Ee 's/.*(rea|int|exp|rec|fai|ok).*/\1/') in
case $(echo ${DEVICESTRING}|tr '[:upper:]' '[:lower:]'|sed -Ee 's/.*(rea|int|exp|rec|fai|ok).*/\1/') in
int)
ERR=2
ERRORSTRING="${ERRORSTRING} / ${DEVICENAME}: DEGRADED"
Expand All @@ -35,15 +35,15 @@ do
ERRORSTRING="${ERRORSTRING} / ${DEVICENAME}: FAILED"
;;
rec)
if ! [ "${ERR}" = 2 -o "${ERR}" = 3 ]; then ERR=1;fi
if ! [ "${ERR}" = 2 ] || [ "${ERR}" = 3 ]; then ERR=1;fi
ERRORSTRING="${ERRORSTRING} / ${DEVICENAME}: rebuilding"
;;
exp)
if ! [ "${ERR}" = 2 -o "${ERR}" = 3 ]; then ERR=1;fi
if ! [ "${ERR}" = 2 ] || [ "${ERR}" = 3 ]; then ERR=1;fi
ERRORSTRING="${ERRORSTRING} / ${DEVICENAME}: expanding"
;;
rea)
if ! [ "${ERR}" = 2 -o "${ERR}" = 3 ]; then ERR=1;fi
if ! [ "${ERR}" = 2 ] || [ "${ERR}" = 3 ]; then ERR=1;fi
ERRORSTRING="${ERRORSTRING} / ${DEVICENAME}: ready for recovery"
;;
ok)
Expand All @@ -57,10 +57,10 @@ if [ "${1}" ]
then
if [ "${ERRORSTRING}" ]
then
echo "${ERRORSTRING} ${OKSTRING}"|sed s/"^\/ "//|mail -s "$(hostname -s): ${0} reports errors" -E ${*}
echo "${ERRORSTRING} ${OKSTRING}"|sed s/"^\/ "//|mail -s "$(hostname -s): ${0} reports errors" -E "${@}"
fi
else
if [ "${ERRORSTRING}" -o "${OKSTRING}" ]
if [ "${ERRORSTRING}" ] || [ "${OKSTRING}" ]
then
echo ${ERRORSTRING} ${OKSTRING}|sed s/"^\/ "//
exit ${ERR}
Expand Down

0 comments on commit 30a6045

Please sign in to comment.