1
0
mirror of https://git.openwrt.org/feed/packages.git synced 2024-06-14 19:33:59 +02:00
openwrt-packages/net/nut/files/nutshutdown
Sven Roederer e9a109cc8c nut: fix typo in nutshutdown script
Even it's only cosmetic and should not affect the function of regular system,
fix the name of the IPKG_INSTROOT variable.
Typo was added long ago with 8400c9a6ec.

Signed-off-by: Sven Roederer <devel-sven@geroedel.de>
(cherry picked from commit f25f49a8b7)
2021-04-06 14:51:29 -07:00

52 lines
1.0 KiB
Bash
Executable File

#!/bin/sh
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
stop_instance() {
/etc/init.d/nut-server stop "$1"
}
shutdown_instance() {
local cfg="$1"
config_get driver "$cfg" driver "usbhid-ups"
# Only FSD if killpower was indicated
if [ -f /var/run/killpower ]; then
/lib/nut/"${driver}" -a "$cfg" -k
fi
}
do_fsd() {
if [ -f /var/run/killpower ]; then
# Only make FS readonly if we are doing an FSD
mount -o remount,ro /overlay /overlay
mount -o remount,ro / /
. ${IPKG_INSTROOT}/lib/functions.sh
if [ -f /etc/config/nut_server ]; then
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
rm -f /var/run/killpower
poweroff
# And just in case
sleep 120
# Uh-oh failed to poweroff UPS
reboot -f
else
poweroff
fi
else
poweroff
fi
}
do_fsd