Skip to content

Commit

Permalink
clients/upssched.c: let UPSNAME@localhost specs copied from upsmon co…
Browse files Browse the repository at this point in the history
…nfig "just work" [networkupstools#1858]
  • Loading branch information
jimklimov committed Feb 28, 2023
1 parent d361816 commit e6d3bbe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,10 @@ https://github.com/networkupstools/nut/milestone/8
- Clarified documentation in codebase according to end-user feedback [#1721,
#1750 and others over time]

- upssched: let `UPSNAME@localhost` specification strings copied from
upsmon config "just work" (previously only exact UPSNAME matches were
supported) [#1858]

- Several fixes for `upsmon` behavior [#1761, #1680...], including new
ability to configure default POWERDOWNFLAG location -- packagers are
encouraged to pick optimal location for their distributions (which
Expand Down
7 changes: 7 additions & 0 deletions clients/upssched.c
Original file line number Diff line number Diff line change
Expand Up @@ -1264,6 +1264,13 @@ static int conf_arg(size_t numargs, char **arg)
/* AT <notifytype> <upsname> <command> <cmdarg1> [<cmdarg2>] */
if (!strcmp(arg[0], "AT")) {

if (str_ends_with(arg[2], "@localhost")) {
/* Truncate: */
arg[2][strlen(arg[2]) - strlen("@localhost")] = '\0';
/* Make a little noise, but do not trash syslog about this: */
upsdebugx(1, "WARNING: The @localhost in UPS identifier is redundant for upssched");
}

/* don't use arg[5] unless we have it... */
if (numargs > 5)
parse_at(arg[1], arg[2], arg[3], arg[4], arg[5]);
Expand Down

0 comments on commit e6d3bbe

Please sign in to comment.