Skip to content

Commit bd03859

Browse files
committed
feat: Add check and warning for reboot inhibitor
1 parent 3df5f34 commit bd03859

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/nixos-anywhere.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -914,6 +914,29 @@ SSH
914914
915915
nixosReboot() {
916916
step Rebooting
917+
918+
# disable debug output temporarily to prevent log spam
919+
set +x
920+
921+
local inhibited
922+
inhibited=$(
923+
runSsh sh <<SSH
924+
if command -v systemd-inhibit 2>/dev/null; then
925+
systemd-inhibit --list | grep "shutdown"
926+
fi
927+
SSH
928+
)
929+
if [[ -n "${inhibited}" ]]; then
930+
echo "WARNING: Reboot is currently inhibited. Manual reboot may be required. Run 'systemd-inhibit --list' on the target for further details" 2>&1
931+
if [[ -n ${enableDebug} ]]; then
932+
echo "${inhibited}" 2>&1
933+
fi
934+
fi
935+
936+
if [[ -n ${enableDebug} ]]; then
937+
set -x
938+
fi
939+
917940
runSsh sh <<SSH
918941
if command -v zpool >/dev/null && [ "\$(zpool list)" != "no pools available" ]; then
919942
# we always want to export the zfs pools so people can boot from it without force import

0 commit comments

Comments
 (0)