aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/zed/zed.d/all-syslog.sh
diff options
context:
space:
mode:
authorChris Dunlap <[email protected]>2015-02-17 17:23:54 -0800
committerBrian Behlendorf <[email protected]>2015-04-27 12:08:01 -0700
commitaded9a6814c9f6260437bc186ad08debc5d0b6c8 (patch)
tree9ad772349943effa8953d8ec723aff8aa07320a4 /cmd/zed/zed.d/all-syslog.sh
parent0336f3d001c76625281919bcf9e534d1976f3c36 (diff)
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 <[email protected]>
Diffstat (limited to 'cmd/zed/zed.d/all-syslog.sh')
-rwxr-xr-xcmd/zed/zed.d/all-syslog.sh9
1 files changed, 4 insertions, 5 deletions
diff --git a/cmd/zed/zed.d/all-syslog.sh b/cmd/zed/zed.d/all-syslog.sh
index acf9e83bd..b34d17cef 100755
--- a/cmd/zed/zed.d/all-syslog.sh
+++ b/cmd/zed/zed.d/all-syslog.sh
@@ -1,11 +1,10 @@
#!/bin/sh
#
# Log the zevent via syslog.
-#
-test -f "${ZED_ZEDLET_DIR}/zed.rc" && . "${ZED_ZEDLET_DIR}/zed.rc"
-logger -t "${ZED_SYSLOG_TAG:=zed}" -p "${ZED_SYSLOG_PRIORITY:=daemon.notice}" \
- eid="${ZEVENT_EID}" class="${ZEVENT_SUBCLASS}" \
- "${ZEVENT_POOL:+pool=$ZEVENT_POOL}"
+[ -f "${ZED_ZEDLET_DIR}/zed.rc" ] && . "${ZED_ZEDLET_DIR}/zed.rc"
+. "${ZED_ZEDLET_DIR}/zed-functions.sh"
+zed_log_msg "eid=${ZEVENT_EID}" "class=${ZEVENT_SUBCLASS}" \
+ "${ZEVENT_POOL:+"pool=${ZEVENT_POOL}"}"
exit 0