diff options
author | Tony Vroon <chainsaw@gentoo.org> | 2017-06-30 18:48:44 +0100 |
---|---|---|
committer | Tony Vroon <chainsaw@gentoo.org> | 2017-06-30 18:48:44 +0100 |
commit | 3ae4420681873e7d3f60758fce31f25b5d426ead (patch) | |
tree | e1957331458f84c3680d8d3580fc8b48565dc22d /sys-apps/cciss_vol_status/files/cciss_vol_status.cron2 | |
parent | media-libs/mlt: Drop old (diff) | |
download | gentoo-3ae4420681873e7d3f60758fce31f25b5d426ead.tar.gz gentoo-3ae4420681873e7d3f60758fce31f25b5d426ead.tar.bz2 gentoo-3ae4420681873e7d3f60758fce31f25b5d426ead.zip |
sys-apps/cciss_vol_status: Version bump to 1.12; new cron script by Michael "mjo" Orlitzky closes bug #561868.
Package-Manager: portage-2.3.6
Diffstat (limited to 'sys-apps/cciss_vol_status/files/cciss_vol_status.cron2')
-rw-r--r-- | sys-apps/cciss_vol_status/files/cciss_vol_status.cron2 | 52 |
1 files changed, 52 insertions, 0 deletions
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 |