mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-11-18 02:20:59 +03:00
aded9a6814
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>
25 lines
532 B
Bash
Executable File
25 lines
532 B
Bash
Executable File
#!/bin/sh
|
|
#
|
|
# Log all environment variables to ZED_DEBUG_LOG.
|
|
#
|
|
# This can be a useful aid when developing/debugging ZEDLETs since it shows the
|
|
# environment variables defined for each zevent.
|
|
|
|
[ -f "${ZED_ZEDLET_DIR}/zed.rc" ] && . "${ZED_ZEDLET_DIR}/zed.rc"
|
|
. "${ZED_ZEDLET_DIR}/zed-functions.sh"
|
|
|
|
: "${ZED_DEBUG_LOG:="${TMPDIR:="/tmp"}/zed.debug.log"}"
|
|
|
|
lockfile="$(basename -- "${ZED_DEBUG_LOG}").lock"
|
|
|
|
umask 077
|
|
zed_lock "${lockfile}"
|
|
exec >> "${ZED_DEBUG_LOG}"
|
|
|
|
printenv | sort
|
|
echo
|
|
|
|
exec >&-
|
|
zed_unlock "${lockfile}"
|
|
exit 0
|