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
845 B

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