[Nut-upsuser] NUT Client shuts down when performing runtime calibration on APC UPS

Roger Price roger at rogerprice.org
Wed Jan 11 12:58:52 UTC 2017


On Wed, 11 Jan 2017, Merk - Oliver wrote:

> nas4free: /# more /usr/local/bin/upssched-cmd
> #!/bin/sh

I would strongly recommend specifying which script interpreter is to be 
used: dash, bash, csh, ksh, ...  For example

  #!/bin/bash

There seem to be too many case statements in this script.

> case "${1}" in
>        shutdown-warning)
>                _shutdowntimer=`configxml_get "//ups/shutdowntimer"`;
>                _message="${_notifymessage}.
> Shutdown imminent in ${_shutdowntimer} seconds.";;
>
>        shutdown)

This is where a test looking for the letters "CAL" in ups.status is 
needed.  If found, then issue a modified message.

>                _message="${_notifymessage}.
> Shutdown in progress.";
>        ONLINE)
>                _notifymessage="UPS ${UPSNAME} - Running on line power";;

Isn't this just duplication?  Can $1 really take the value ONLINE ?

> case "${1}" in
>        shutdown-warning)
>                _shutdowntimer=`configxml_get "//ups/shutdowntimer"`;
>                _message="${_notifymessage}.
> Shutdown imminent in ${_shutdowntimer} seconds.";;
>
>        shutdown)
>                _message="${_notifymessage}.

More duplication! Test needed here for "CAL" in ups.status. If found, no 
shutdown.

> Shutdown in progress.";
>                shutdown -p now ${_message};;

It looks as if this script needs a thorough code review.

Roger



More information about the Nut-upsuser mailing list