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.

53 lines
1000 B

  1. #!/bin/sh
  2. . "${IPKG_INSTROOT}"/lib/functions.sh
  3. REMOVEDEFAULTNOTIFY=0
  4. SKIPADDSYSLOG=0
  5. SKIPADDEXEC=0
  6. SKIPADDNOTIFYCMD=0
  7. upsmon() {
  8. local cfg="$1"
  9. local val
  10. config_get val "$cfg" notifycmd
  11. if [ -n "$val" ]; then
  12. SKIPADDNOTIFYCMD=1
  13. fi
  14. config_get val "$cfg" defaultnotify
  15. if [ -n "$val" ]; then
  16. if echo "$val" |grep -q "IGNORE"; then
  17. REMOVEDEFAULTNOTIFY=1
  18. else
  19. SKIPADDSYSLOG=1
  20. if echo "$val" |grep -q "EXEC"; then
  21. SKIPADDEXEC=1
  22. fi
  23. fi
  24. fi
  25. }
  26. config_load nut_monitor
  27. config_foreach upsmon upsmon
  28. uci set nut_monitor.@upsmon[-1]=upsmon
  29. if [ "$SKIPADDNOTIFYCMD" != "1" ]; then
  30. uci set nut_monitor.@upsmon[-1].notifycmd=/usr/sbin/upssched
  31. fi
  32. if [ "$REMOVEDEFAULTNOTIFY" = "1" ]; then
  33. uci delete nut_monitor.@upsmon[-1].defaultnotify || true
  34. fi
  35. if [ "$SKIPADDEXEC" != "1" ]; then
  36. uci add_list nut_monitor.@upsmon[-1].defaultnotify="EXEC"
  37. fi
  38. if [ "$SKIPADDSYSLOG" != "1" ]; then
  39. uci add_list nut_monitor.@upsmon[-1].defaultnotify="SYSLOG"
  40. fi
  41. uci commit nut_monitor