@@ -57,6 +57,8 @@ hasDoas=
5757hasWget=
5858hasCurl=
5959hasSetsid=
60+ hasGrep=
61+ hasSystemdInhibit=
6062hasNixOSFacter=
6163
6264tempDir=$( mktemp -d)
@@ -585,7 +587,7 @@ importFacts() {
585587
586588 # Necessary to prevent Bash erroring before printing out which fact had an issue
587589 set +u
588- for var in isOs isArch isInstaller isContainer isRoot hasIpv6Only hasTar hasCpio hasSudo hasDoas hasWget hasCurl hasSetsid; do
590+ for var in isOs isArch isInstaller isContainer isRoot hasIpv6Only hasTar hasCpio hasSudo hasDoas hasWget hasCurl hasSetsid hasGrep hasSystemdInhibit ; do
589591 if [[ -z ${! var} ]]; then
590592 abort " Failed to retrieve fact $var from host"
591593 fi
@@ -915,28 +917,30 @@ SSH
915917nixosReboot () {
916918 step Rebooting
917919
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 >/dev/null && systemd-inhibit --list | grep -q 'shutdown'; then
925- systemd-inhibit --list
926- fi
920+ if [[ $hasSystemdInhibit == " y" ]] && [[ $hasGrep == " y" ]]; then
921+ # disable debug output temporarily to prevent log spam
922+ set +x
923+
924+ local inhibited
925+ inhibited=$(
926+ runSsh sh << SSH
927+ if systemd-inhibit --list | grep -q 'shutdown'; then
928+ systemd-inhibit --list
929+ fi
927930SSH
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+ )
932+ if [ -n " ${inhibited} " ]; then
933+ echo " WARNING: Reboot is currently inhibited. Manual reboot may be required. Run 'systemd-inhibit --list' on the target for further details" 2>&1
934+ if [[ -n ${enableDebug} ]]; then
935+ echo " ${inhibited} " 2>&1
936+ fi
937+ fi
938+
931939 if [[ -n ${enableDebug} ]]; then
932- echo " ${inhibited} " 2>&1
940+ set -x
933941 fi
934942 fi
935943
936- if [[ -n ${enableDebug} ]]; then
937- set -x
938- fi
939-
940944 runSsh sh << SSH
941945 if command -v zpool >/dev/null && [ "\$ (zpool list)" != "no pools available" ]; then
942946 # we always want to export the zfs pools so people can boot from it without force import
0 commit comments