nut: Backport fixes from master

Backport and squash the following commits from master:

  5790053eb nut: Add missing conffiles
  ceff68837 nut: Reorganize nut-server to clarify nut-driver
  f6a2a97d2 nut: Use 'real' procd init for nut-monitor
  918a62f91 nut: Make FSD really work
  a2f64b3ba nut: Reduce user error with POWERDOWNFLAG
  461393810 nut: Use quotes around filenames
  1b6dbe7a7 nut: Remove duplicate/extraneous lines
  0a49d0ffb nut: Fix checking for path before it exists
  3b5a8eee8 nut: Various startup fixes for monitor and server
  44e57d4bd nut: Fix variables for NUT drivers
  36fd59dc7 nut: Fix extraneous config_get
  192b0f164 nut: Fix a typo in setting a driver parameter
  f48b060fa nut: Fix upsd runs as root

And bump PKG_RELEASE

Signed-off-by: Daniel F. Dickinson <cshored@thecshore.com>
This commit is contained in:
Daniel F. Dickinson
2018-08-20 20:06:31 -04:00
parent e6769fc7ef
commit bb1b12733e
7 changed files with 395 additions and 165 deletions
+41
View File
@@ -0,0 +1,41 @@
#!/bin/sh
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
. /lib/functions.sh
mount -o remount,ro /overlay /overlay
mount -o remount,ro / /
stop_instance() {
/etc/init.d/nut-server stop "$1"
}
shutdown_instance() {
local cfg="$1"
config_get driver "$cfg" driver "usbhid-ups"
/lib/nut/${driver} -a "$cfg" -k
}
[ -f /var/run/killpower ] && {
[ -f /etc/config/nut_server ] && {
config_load nut_server
# Can't FSD unless drivers are stopped
config_foreach stop_instance driver
# Driver will wait 'offdelay' before shutting down
config_foreach shutdown_instance driver
# So this can happen
poweroff
# And just in case
sleep 120
# Uh-oh failed to poweroff UPS
reboot -f
} || {
poweroff
}
} || {
poweroff
}