]> git.99rst.org Git - openwrt-packages.git/blob
8400c9a6ec799
[openwrt-packages.git] /
1 #!/bin/sh
2 #
3 # This is free software, licensed under the GNU General Public License v2.
4 # See /LICENSE for more information.
5 #
6
7 stop_instance() {
8 /etc/init.d/nut-server stop "$1"
9 }
10
11 shutdown_instance() {
12 local cfg="$1"
13 config_get driver "$cfg" driver "usbhid-ups"
14
15 # Only FSD if killpower was indicated
16 if [ -f /var/run/killpower ]; then
17 /lib/nut/"${driver}" -a "$cfg" -k
18 fi
19 }
20
21 do_fsd() {
22 if [ -f /var/run/killpower ]; then
23 # Only make FS readonly if we are doing an FSD
24 mount -o remount,ro /overlay /overlay
25 mount -o remount,ro / /
26
27 . ${IPKG_INSTOOT}/lib/functions.sh
28
29 if [ -f /etc/config/nut_server ]; then
30 config_load nut_server
31
32 # Can't FSD unless drivers are stopped
33 config_foreach stop_instance driver
34 # Driver will wait 'offdelay' before shutting down
35 config_foreach shutdown_instance driver
36 # So this can happen
37 rm -f /var/run/killpower
38 poweroff
39 # And just in case
40 sleep 120
41 # Uh-oh failed to poweroff UPS
42 reboot -f
43 else
44 poweroff
45 fi
46 else
47 poweroff
48 fi
49 }
git clone https://git.99rst.org/PROJECT