On Debian 13 (or any system using fwupd), the fwupdmgr update command by default returns a zero exit code even if there are devices requiring user action (e.g., firmware updates that need manual intervention, like a reboot or BIOS setting change). This is because fwupdmgr considers the command successful if it executed without errors, regardless of pending user actions.
To make fwupdmgr update return a non-zero exit code when devices require user action, you need to:
fwupdmgr update.fwupdmgr get-devices and jqYou can parse the output of fwupdmgr get-devices --json to detect devices with Flags: needs-reboot, needs-user-action, etc. and exit accordingly.
Example Script:
bash#!/bin/bash # Run the update fwupdmgr update # Check for devices requiring user action if fwupdmgr get-devices --json | jq -e '.Devices[] | select(.Flags | contains("needs-user-action") or contains("needs-reboot"))' >/dev/null; then echo "Devices require user action. Exiting with non-zero code." exit 1 else echo "No user action required. Exiting with zero code." exit 0 fi
fwupdmgr get-updatesAlternatively, you can use fwupdmgr get-updates to check for pending updates that require user action:
bash#!/bin/bash # Run the update fwupdmgr update # Check for updates requiring user action if fwupdmgr get-updates | grep -q "User action required"; then echo "User action required. Exiting with non-zero code." exit 1 else echo "No user action required. Exiting with zero code." exit 0 fi
fwupdmgr --json and jq (More Robust)For a more robust approach, use the JSON output of fwupdmgr get-updates --json to check for UserActionRequired:
bash#!/bin/bash # Run the update fwupdmgr update # Check for updates requiring user action if fwupdmgr get-updates --json | jq -e '.Updates[] | select(.UserActionRequired == true)' >/dev/null; then echo "User action required. Exiting with non-zero code." exit 1 else echo "No user action required. Exiting with zero code." exit 0 fi
jq is installed (sudo apt install jq).UserActionRequired, needs-reboot) may vary depending on the fwupd version. Adjust the script accordingly.fwupdmgr update), use fwupdmgr get-updates first.Le Chat can make mistakes. Check answers. Learn more