mirror of
https://github.com/novatiq/packages.git
synced 2026-04-30 07:28:39 +01:00
nut: Make FSD really work
Forced shutdown of the UPS was not actually happening before due to lack of specific commands doing the shutdown. This (and the nut-driver initscript) fix that. Signed-off-by: Daniel F. Dickinson <cshored@thecshore.com>
This commit is contained in:
Executable
+41
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user