Skip to content

Commit

Permalink
zreport: handle hooks that run once and are completed
Browse files Browse the repository at this point in the history
  • Loading branch information
zdykstra committed Jan 27, 2025
1 parent 87512e0 commit 849207e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion zfsbootmenu/lib/zfsbootmenu-core.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2029,13 +2029,20 @@ zreport() {

colorize orange "\n>> Enabled hooks\n"
for hook in /libexec/hooks/*.d/*; do
[ -x "${hook}" ] && echo "* $( colorize green "${hook}")"
ENABLED=
if [[ "${hook}" =~ \.completed$ ]] ; then
hook="${hook//.completed/ (run once, completed)}"
ENABLED=1
fi
[ -x "${hook}" ] && ENABLED=1
[ -n "${ENABLED}" ] && echo "* $( colorize green "${hook}")"
done

colorize orange "\n>> Disabled hooks\n"
for hook in /libexec/hooks/*.d/*; do
[ -f "${hook}" ] || continue
[ -x "${hook}" ] && continue
[[ "${hook}" =~ \.completed$ ]] && continue
echo "* $( colorize red "${hook}")"
done

Expand Down
1 change: 1 addition & 0 deletions zfsbootmenu/libexec/zfsbootmenu-run-hooks
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ for _hook in "/libexec/hooks/${hook_stage}"/*; do
if [ "${ONE_SHOT_HOOKS}" -eq 1 ] >/dev/null 2>&1; then
zinfo "Disabling hook after execution: ${_hook}"
chmod 000 "${_hook}"
mv "${_hook}" "${_hook}.completed"
fi
done

Expand Down

0 comments on commit 849207e

Please sign in to comment.