From 4730de75dd3ed64c826058d3cfd3d1b4735f1f2b Mon Sep 17 00:00:00 2001 From: sudolulo Date: Mon, 15 Jun 2026 17:51:56 +0000 Subject: [PATCH] Improve midclt error handling in install.sh - Capture midclt output via $(...) instead of > /dev/null so that failure detail (which midclt writes to stdout on TrueNAS) is preserved and shown to the user on error rather than silently discarded - Expand update failure hint from a bare query command to an actionable recovery path: show the midclt output, then print the exact delete command with the known stale ID so the user can remove it and retry --- install.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/install.sh b/install.sh index 9423732..14cefd9 100755 --- a/install.sh +++ b/install.sh @@ -72,17 +72,20 @@ for s in json.load(sys.stdin): if [ -n "$EXISTING_ID" ]; then echo "Already registered (id=$EXISTING_ID). Updating path and enabling ..." - if ! midclt call initshutdownscript.update "$EXISTING_ID" \ - "{\"enabled\": true, \"script\": \"$PATCH_DIR/patch/apply.sh\"}" > /dev/null; then + if ! _midclt_out=$(midclt call initshutdownscript.update "$EXISTING_ID" \ + "{\"enabled\": true, \"script\": \"$PATCH_DIR/patch/apply.sh\"}" 2>&1); then echo "ERROR: Failed to update PREINIT hook (id=$EXISTING_ID)." >&2 - echo " midclt call initshutdownscript.query '[]'" >&2 + [ -n "$_midclt_out" ] && echo " midclt: $_midclt_out" >&2 + echo " To remove the stale entry and retry:" >&2 + echo " midclt call initshutdownscript.delete $EXISTING_ID" >&2 exit 1 fi else - if ! midclt call initshutdownscript.create \ + if ! _midclt_out=$(midclt call initshutdownscript.create \ "{\"type\":\"SCRIPT\",\"script\":\"$PATCH_DIR/patch/apply.sh\",\"when\":\"PREINIT\",\"enabled\":true,\"comment\":\"$_HOOK_COMMENT\"}" \ - > /dev/null; then + 2>&1); then echo "ERROR: Failed to register PREINIT hook." >&2 + [ -n "$_midclt_out" ] && echo " midclt: $_midclt_out" >&2 exit 1 fi echo "Registered."