Skip to content

Instantly share code, notes, and snippets.

@bmastenbrook
Created July 5, 2019 02:05
Show Gist options
  • Save bmastenbrook/51f36becfe7078da12c5782ab6f89b47 to your computer and use it in GitHub Desktop.
Save bmastenbrook/51f36becfe7078da12c5782ab6f89b47 to your computer and use it in GitHub Desktop.
zed script to load keys on pool import
#!/bin/sh
#
# Log the zevent via syslog.
#
# OS X notification script.
function notify {
sudo -u "$(stat -f '%Su' /dev/console)" /usr/bin/osascript -e 'display notification "'"$1"'" with title "'"$2"'"'
}
test -f "${ZED_ZEDLET_DIR}/zed.rc" && . "${ZED_ZEDLET_DIR}/zed.rc"
test -n "${ZEVENT_POOL}" || exit 5
test -n "${ZEVENT_SUBCLASS}" || exit 5
if [ "${ZEVENT_SUBCLASS}" = "pool_import" ]; then
cmd="import"
/usr/local/bin/zfs mount -la < /dev/null # load keys
else
cmd="export"
fi
logger -t "${ZED_SYSLOG_TAG:=zed}" \
-p "${ZED_SYSLOG_PRIORITY:=daemon.warning}" \
"Pool $cmd ${ZEVENT_POOL}"
notify "Pool ${ZEVENT_POOL} ${cmd}ed." "Pool ${cmd}"
echo 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment