Cleanup ZEDLETs

This commit factors out several common ZEDLET code blocks into
zed-functions.sh.  This shortens the length of the scripts, thereby
(hopefully) making them easier to understand and maintain.

In addition, this commit revamps the coding style used by the
scripts to be more consistent and (again, hopefully) maintainable.
It now mostly follows the Google Shell Style Guide.  I've tried to
assimilate the following resources:

  Google Shell Style Guide
  https://google-styleguide.googlecode.com/svn/trunk/shell.xml

  Dash as /bin/sh
  https://wiki.ubuntu.com/DashAsBinSh

  Filenames and Pathnames in Shell: How to do it Correctly
  http://www.dwheeler.com/essays/filenames-in-shell.html

  Common shell script mistakes
  http://www.pixelbeat.org/programming/shell_script_mistakes.html

Finally, this commit updates the exit codes used by the ZEDLETs to be
more consistent with one another.

All scripts run cleanly through ShellCheck <http://www.shellcheck.net/>.
All scripts have been tested on bash and dash.

Signed-off-by: Chris Dunlap <cdunlap@llnl.gov>
This commit is contained in:
Chris Dunlap
2015-02-17 17:23:54 -08:00
committed by Brian Behlendorf
parent 0336f3d001
commit aded9a6814
11 changed files with 624 additions and 331 deletions
+36 -10
View File
@@ -1,34 +1,60 @@
##
# zed.rc
##
##
# Absolute path to the debug output file.
#
#ZED_DEBUG_LOG="/tmp/zed.debug.log"
##
# Email address of the zpool administrator.
# Email will only be sent if ZED_EMAIL is defined.
# Disabled by default; uncomment to enable.
#
#ZED_EMAIL="root"
##
# Minimum number of seconds between emails for a similar event.
#
#ZED_EMAIL_INTERVAL_SECS=3600
##
# Email verbosity.
# If set to 0, suppress email if the pool is healthy.
# If set to 1, send email regardless of pool health.
#
#ZED_EMAIL_VERBOSE=0
# Minimum number of seconds between emails sent for a similar event.
#ZED_EMAIL_INTERVAL_SECS="3600"
##
# Default directory for zed lock files.
#
#ZED_LOCKDIR="/var/lock"
##
# Default directory for zed state files.
#
#ZED_RUNDIR="/var/run"
# The syslog priority (eg, specified as a "facility.level" pair).
#ZED_SYSLOG_PRIORITY="daemon.notice"
# The syslog tag for marking zed events.
#ZED_SYSLOG_TAG="zed"
##
# Replace a device with a hot spare after N checksum errors are detected.
# Disabled by default; uncomment to enable.
#
#ZED_SPARE_ON_CHECKSUM_ERRORS=10
##
# Replace a device with a hot spare after N I/O errors are detected.
# Disabled by default; uncomment to enable.
#
#ZED_SPARE_ON_IO_ERRORS=1
# Replace a device with a hot spare after N checksum errors are detected.
#ZED_SPARE_ON_CHECKSUM_ERRORS=10
##
# The syslog priority (e.g., specified as a "facility.level" pair).
#
#ZED_SYSLOG_PRIORITY="daemon.notice"
##
# The syslog tag for marking zed events.
#
#ZED_SYSLOG_TAG="zed"