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

_______________________________________________
Nut-upsuser mailing list
Nut-upsuser@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/nut-upsuser

Reply via email to