Skip to content

Commit 7bee9a5

Browse files
authored
Merge cccbd87 into f33d134
2 parents f33d134 + cccbd87 commit 7bee9a5

3 files changed

Lines changed: 37 additions & 3 deletions

File tree

NEWS.adoc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,16 @@ https://github.com/networkupstools/nut/milestone/9
213213
with either or both, maximizing compatibility with old and new setups.
214214
[#2946]
215215

216+
- `upsmon` client:
217+
* Clearer debug logging of `SHUTDOWNCMD` and `NOTIFYCMD` that would be used
218+
(or warnings that none was set); flush output buffers after these messages
219+
and after each main loop cycle, so any emitted text is seen in a timely
220+
manner. [issue #3003, PR #3008]
221+
222+
- The `nutshutdown` script (end-game integration for UPS power-off in case
223+
of FSD initiated by `upsmon`) was updated to consider `MODE=none` set in
224+
`nut.conf` and bail out quietly. [issue #2935, PR #3008]
225+
216226
- Manual page recipes and contents:
217227
* Introduced handling (possibly rewriting) for man page section "Overviews,
218228
conventions, and miscellaneous" (commonly number 7), to deliver support

clients/upsmon.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3823,11 +3823,22 @@ int main(int argc, char *argv[])
38233823
if (checking_flag)
38243824
exit(check_pdflag());
38253825

3826-
if (shutdowncmd == NULL)
3826+
if (shutdowncmd == NULL) {
38273827
printf("Warning: no shutdown command defined%s\n",
38283828
(minsupplies < 1)
38293829
? ", but that is OK for a monitoring-only client."
38303830
: "!");
3831+
fflush(stdout);
3832+
} else {
3833+
upsdebugx(1, "will use a shutdown command (SHUTDOWNCMD): '%s'", shutdowncmd);
3834+
}
3835+
3836+
if (notifycmd == NULL) {
3837+
printf("Warning: no custom notification command defined, just so you know\n");
3838+
fflush(stdout);
3839+
} else {
3840+
upsdebugx(1, "will use custom notification command (NOTIFYCMD): '%s'", notifycmd);
3841+
}
38313842

38323843
/* we may need to get rid of a flag from a previous shutdown */
38333844
if (powerdownflag != NULL)
@@ -4162,8 +4173,10 @@ int main(int argc, char *argv[])
41624173
}
41634174

41644175
end_loop_cycle:
4165-
/* No-op to avoid a warning about label at end of compound statement */
4166-
(void)1;
4176+
/* If anyone printed anything, be sure it is output
4177+
* in a timely manner, not buffered indefinitely: */
4178+
fflush(stdout);
4179+
fflush(stderr);
41674180
}
41684181

41694182
upslogx(LOG_INFO, "Signal %d: exiting", exit_flag);

scripts/systemd/nutshutdown.in

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,17 @@ if [ -s "@CONFPATH@/nut.conf" ]; then
3737
. "@CONFPATH@/nut.conf" || true
3838
fi
3939

40+
if [ x"${MODE}" = xnone ]; then
41+
# Per https://github.com/networkupstools/nut/issues/2935
42+
# it is possible that NUT gets administratively disabled
43+
# some time after a POWERDOWNFLAG file is created, and
44+
# before it is deleted. In this case it never got deleted,
45+
# and if that was in a persistent location - then every OS
46+
# shutdown or reboot got treated as FSD with UPS power-off.
47+
echo "$@: MODE=none so quetly exiting" >&2
48+
exit 0
49+
fi
50+
4051
[ x"${POWEROFF_QUIET-}" = xtrue ] \
4152
|| POWEROFF_QUIET="false"
4253

0 commit comments

Comments
 (0)