@@ -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,26 +917,28 @@ SSH
915917nixosReboot () {
916918 step Rebooting
917919
918- # disable debug output temporarily to prevent log spam
919- set +x
920+ if [[ $hasSystemdInhibit == " y" ]] && [[ $hasGrep == " y" ]]; then
921+ # disable debug output temporarily to prevent log spam
922+ set +x
920923
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
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- if [[ -n ${enableDebug} ]]; then
932- echo " ${inhibited} " 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
933937 fi
934- fi
935938
936- if [[ -n ${enableDebug} ]]; then
937- set -x
939+ if [[ -n ${enableDebug} ]]; then
940+ set -x
941+ fi
938942 fi
939943
940944 runSsh sh << SSH
0 commit comments