You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
807 B

  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. . /lib/functions.sh
  7. mount -o remount,ro /overlay /overlay
  8. mount -o remount,ro / /
  9. stop_instance() {
  10. /etc/init.d/nut-server stop "$1"
  11. }
  12. shutdown_instance() {
  13. local cfg="$1"
  14. config_get driver "$cfg" driver "usbhid-ups"
  15. /lib/nut/${driver} -a "$cfg" -k
  16. }
  17. [ -f /var/run/killpower ] && {
  18. [ -f /etc/config/nut_server ] && {
  19. config_load nut_server
  20. # Can't FSD unless drivers are stopped
  21. config_foreach stop_instance driver
  22. # Driver will wait 'offdelay' before shutting down
  23. config_foreach shutdown_instance driver
  24. # So this can happen
  25. poweroff
  26. # And just in case
  27. sleep 120
  28. # Uh-oh failed to poweroff UPS
  29. reboot -f
  30. } || {
  31. poweroff
  32. }
  33. } || {
  34. poweroff
  35. }