nut: Prevent FSD when not specifically requested 7910/head
authorDaniel F. Dickinson <cshored@thecshore.com>
Sun, 6 Jan 2019 23:32:52 +0000 (18:32 -0500)
committerDaniel F. Dickinson <cshored@thecshore.com>
Tue, 8 Jan 2019 09:07:01 +0000 (04:07 -0500)
Under certain circumstances nutshutdown was causing a forced
shutdown of the UPS even though killpower was not indicated.
Prevent that.  Also clarify the logic for powering off server
by avoiding && || chains.

Signed-off-by: Daniel F. Dickinson <cshored@thecshore.com>
net/nut/Makefile
net/nut/files/nutshutdown

index 985feae5da512458a1c6faa53e4973f9d5a357c6..5dd635c2725691bab3906836cbfc678eda0597b8 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=nut
 PKG_VERSION:=2.7.4
-PKG_RELEASE:=13
+PKG_RELEASE:=14
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=http://www.networkupstools.org/source/2.7/
index e4fd962cd79074ec773120cd30fe8781ca2e9a61..ad1cda2d34b15e8ee8da164fe8da6bb7916e2aeb 100755 (executable)
@@ -16,11 +16,14 @@ stop_instance() {
 shutdown_instance() {
        local cfg="$1"
        config_get driver "$cfg" driver "usbhid-ups"
-       /lib/nut/${driver} -a "$cfg" -k
+       # Only FSD if killpower was indicated
+       if [ -f /var/run/killpower ]; then
+               /lib/nut/${driver} -a "$cfg" -k
+       fi
 }
 
-[ -f /var/run/killpower ] && {
-       [ -f /etc/config/nut_server ] && {
+if [ -f /var/run/killpower ]; then
+       if [ -f /etc/config/nut_server ]; then
                config_load nut_server
 
                # Can't FSD unless drivers are stopped
@@ -33,9 +36,9 @@ shutdown_instance() {
                sleep 120
                # Uh-oh failed to poweroff UPS
                reboot -f
-       } || {
+       else
                poweroff
-       }
-} || {
+       fi
+else
        poweroff
-}
+fi