$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/nut-monitor.init $(1)/etc/init.d/nut-monitor
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/upsmon $(1)/usr/sbin/
+ $(INSTALL_BIN) ./files/nutshutdown $(1)/usr/sbin/nutshutdown
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_CONF) ./files/nut_monitor $(1)/etc/config/nut_monitor
ln -sf /var/etc/nut/upsmon.conf $(1)/etc/nut/upsmon.conf
config_get val "$cfg" minsupplies 1
echo "MINSUPPLIES $val" >> $UPSMON_C
- config_get val "$cfg" shutdowncmd "/sbin/halt"
+ config_get val "$cfg" shutdowncmd "/usr/sbin/nutshutdown"
echo "SHUTDOWNCMD \"$val\"" >> $UPSMON_C
config_get val "$cfg" notifycmd
#config upsmon 'upsmon'
# option runas run-as-user
# option minsupplies 1
-# option shutdowncmd /sbin/halt
+# option shutdowncmd '/usr/sbin/nutshutdown'
# option notifycmd /path/to/cmd
# list defaultnotify SYSLOG
# option pollfreq 5
--- /dev/null
+#!/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
+}