blob: 7270f983f1088e90b72dae4ca00e2e8dd9bc4370 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#!/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
|