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.

44 lines
825 B

  1. #!/bin/sh /etc/rc.common
  2. # Copyright © 2012 OpenWrt.org
  3. #
  4. # This is free software, licensed under the GNU General Public License v2.
  5. # See /LICENSE for more information.
  6. #
  7. START=51
  8. DEFAULT=/etc/default/nut
  9. UPSCGI_C=/var/etc/nut/hosts.conf
  10. nut_upscgi_add() {
  11. local cfg="$1"
  12. local upsname
  13. local hostname
  14. local port
  15. local displayname
  16. config_get upsname "$cfg" upsname
  17. config_get hostname "$cfg" hostname localhost
  18. config_get port "$cfg" port
  19. config_get pass "$cfg" password
  20. system="$upsname@$hostname"
  21. if [ -n "$port" ]; then
  22. system="$system:$port";
  23. fi
  24. config_get displayname "$cfg" displayname
  25. echo "MONITOR $system \"$displayname\"" >> $UPSCGI_C
  26. }
  27. start() {
  28. rm -f $UPSCGI_C
  29. config_load nut_cgi
  30. config_foreach nut_upscgi_add host
  31. chmod 640 /var/etc/nut/hosts.conf
  32. }
  33. stop() {
  34. rm -f $UPSCGI_C
  35. }