diff options
author | V3n3RiX <venerix@redcorelinux.org> | 2017-10-09 18:53:29 +0100 |
---|---|---|
committer | V3n3RiX <venerix@redcorelinux.org> | 2017-10-09 18:53:29 +0100 |
commit | 4f2d7949f03e1c198bc888f2d05f421d35c57e21 (patch) | |
tree | ba5f07bf3f9d22d82e54a462313f5d244036c768 /sys-apps/cciss_vol_status/files |
reinit the tree, so we can have metadata
Diffstat (limited to 'sys-apps/cciss_vol_status/files')
-rw-r--r-- | sys-apps/cciss_vol_status/files/cciss_vol_status.cron | 21 | ||||
-rw-r--r-- | sys-apps/cciss_vol_status/files/cciss_vol_status.cron2 | 52 |
2 files changed, 73 insertions, 0 deletions
diff --git a/sys-apps/cciss_vol_status/files/cciss_vol_status.cron b/sys-apps/cciss_vol_status/files/cciss_vol_status.cron new file mode 100644 index 000000000000..8d1175b45678 --- /dev/null +++ b/sys-apps/cciss_vol_status/files/cciss_vol_status.cron @@ -0,0 +1,21 @@ +#!/bin/sh + +test -x /usr/bin/cciss_vol_status || exit 0 + +STATUS=0 + +if [ -d /proc/driver/cciss ]; then + DEVS=`awk -F: '/^cciss\/c.*d0/{print "/dev/" $1}' /proc/driver/cciss/cciss*` + OUTPUT=`/usr/bin/cciss_vol_status $DEVS` + if [ $? -ne 0 ]; then + printf "%s\n" "$OUTPUT" + exit 1 + fi +fi +# FIXME: This cronjob should also look at the scsi generic nodes +# (/dev/sg*?) to cover the hpsa driver, fibre-attached MSA1000 family +# devices, orthehpahcisr software RAID driver (see cciss_vol_status(8) +# about how to choose the correct nodes -- i don't use these other +# devices, so i cannot verify how to check them cleanly) +# +exit 0 diff --git a/sys-apps/cciss_vol_status/files/cciss_vol_status.cron2 b/sys-apps/cciss_vol_status/files/cciss_vol_status.cron2 new file mode 100644 index 000000000000..43731b48e0ca --- /dev/null +++ b/sys-apps/cciss_vol_status/files/cciss_vol_status.cron2 @@ -0,0 +1,52 @@ +#!/bin/sh + +test -x /usr/bin/cciss_vol_status || exit 0 + +# WARNING: For the hpsa driver, we only support /dev/sda through +# /dev/sdz and /dev/sg0 through /dev/sg9. +DEVICES=$(find /dev -type b \( -path '/dev/cciss/c*d0' \ + -or \ + -path '/dev/sd[a-z]' \ + -or \ + -path '/dev/sg[0-9]' \)) + +if [ -n "${DEVICES}" ]; then + # + # Unsupported devices will generate an error (to stderr) of the form, + # + # cciss_vol_status: /dev/sda: Unknown SCSI device. + # + # We want to ignore these, and fortunately, an exit code of zero + # is returned in this case. So we need only hide the output by + # redirecting stderr elsewhere. But, that also hides errors of the + # form, + # + # cciss_vol_status: open /dev/sda: Permission denied + # + # which we DO want to present to the user. So instead of sending + # stderr to stdout, we redirect it to a temporary file. We then + # show the content of the temporary file to the user if it + # contains errors other than "Unknown SCSI device." + # + TMPFILE=$( mktemp ) + if [ $? -ne 0 ] || [ ! -f "${TMPFILE}" ]; then + echo "${0}: error creating temporary file." >&2 + exit 2 + fi + + OUTPUT=$( /usr/bin/cciss_vol_status ${DEVICES} 2> "${TMPFILE}" ) + if [ $? -ne 0 ]; then + printf "%s\n" "$OUTPUT" + rm -f "${TMPFILE}" + exit 1 + fi + + ERRORS=$( GREP_OPTIONS="" grep -v "Unknown SCSI device" "${TMPFILE}" ) + rm -f "${TMPFILE}" + if [ -n "${ERRORS}" ]; then + echo "${ERRORS}" >&2 + exit 3 + fi +fi + +exit 0 |