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