xref: /freebsd/sys/contrib/openzfs/cmd/zed/zed.d/all-debug.sh (revision 9e5787d2284e187abb5b654d924394a65772e004)
1#!/bin/sh
2#
3# Log all environment variables to ZED_DEBUG_LOG.
4#
5# This can be a useful aid when developing/debugging ZEDLETs since it shows the
6# environment variables defined for each zevent.
7
8[ -f "${ZED_ZEDLET_DIR}/zed.rc" ] && . "${ZED_ZEDLET_DIR}/zed.rc"
9. "${ZED_ZEDLET_DIR}/zed-functions.sh"
10
11: "${ZED_DEBUG_LOG:="${TMPDIR:="/tmp"}/zed.debug.log"}"
12
13zed_exit_if_ignoring_this_event
14
15lockfile="$(basename -- "${ZED_DEBUG_LOG}").lock"
16
17umask 077
18zed_lock "${lockfile}"
19exec >> "${ZED_DEBUG_LOG}"
20
21printenv | sort
22echo
23
24exec >&-
25zed_unlock "${lockfile}"
26exit 0
27