lede-packages-rs

git clone git://archive.git.mtrnord.blog/MTRNord/lede-packages-rs.git
Log | Files | Refs | README | LICENSE

nut-sendmail-notify.default (845B)


      1 #!/bin/sh
      2 
      3 . /lib/functions.sh
      4 
      5 REMOVEDEFAULTNOTIFY=0
      6 SKIPADDSYSLOG=0
      7 SKIPADDEXEC=0
      8 
      9 upsmon() {
     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 
     26 config_load nut_monitor
     27 config_foreach upsmon upsmon
     28 
     29 uci set nut_monitor.@upsmon[-1]=upsmon
     30 uci set nut_monitor.@upsmon[-1].notifycmd=/usr/bin/nut-sendmail-notify
     31 
     32 if [ "$REMOVEDEFAULTNOTIFY" = "1" ]; then
     33 	uci delete nut_monitor.@upsmon[-1].defaultnotify || true
     34 fi
     35 
     36 if [ "$SKIPADDEXEC" != "1" ]; then
     37 	uci add_list nut_monitor.@upsmon[-1].defaultnotify="EXEC"
     38 fi
     39 
     40 if [ "$SKIPADDSYSLOG" != "1" ]; then
     41 	uci add_list nut_monitor.@upsmon[-1].defaultnotify="SYSLOG"
     42 fi
     43 
     44 uci commit nut_monitor