mirror of
https://github.com/novatiq/packages.git
synced 2026-04-29 23:18:42 +01:00
net-nut: Add UPS notifications via sendmail
Add option to send email notification via sendmail (or replacement). Signed-off-by: Daniel Dickinson <lede@cshore.thecshore.com>
This commit is contained in:
Executable
+10
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
/usr/sbin/sendmail root <<EOF
|
||||
From: root
|
||||
To: root
|
||||
Subject: UPS $NOTIFYTYPE Notification
|
||||
|
||||
$1
|
||||
.
|
||||
EOF
|
||||
@@ -0,0 +1,44 @@
|
||||
#!/bin/sh
|
||||
|
||||
. /lib/functions.sh
|
||||
|
||||
REMOVEDEFAULTNOTIFY=0
|
||||
SKIPADDSYSLOG=0
|
||||
SKIPADDEXEC=0
|
||||
|
||||
upsmon() {
|
||||
local cfg="$1"
|
||||
local val
|
||||
|
||||
config_get val "$cfg" defaultnotify
|
||||
if [ -n "$val" ]; then
|
||||
if echo "$val" |grep -q "IGNORE"; then
|
||||
REMOVEDEFAULTNOTIFY=1
|
||||
else
|
||||
SKIPADDSYSLOG=1
|
||||
if echo "$val" |grep -q "EXEC"; then
|
||||
SKIPADDEXEC=1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
config_load nut_monitor
|
||||
config_foreach upsmon upsmon
|
||||
|
||||
uci set nut_monitor.@upsmon[-1]=upsmon
|
||||
uci set nut_monitor.@upsmon[-1].notifycmd=/usr/bin/nut-sendmail-notify
|
||||
|
||||
if [ "$REMOVEDEFAULTNOTIFY" = "1" ]; then
|
||||
uci delete nut_monitor.@upsmon[-1].defaultnotify || true
|
||||
fi
|
||||
|
||||
if [ "$SKIPADDEXEC" != "1" ]; then
|
||||
uci add_list nut_monitor.@upsmon[-1].defaultnotify="EXEC"
|
||||
fi
|
||||
|
||||
if [ "$SKIPADDSYSLOG" != "1" ]; then
|
||||
uci add_list nut_monitor.@upsmon[-1].defaultnotify="SYSLOG"
|
||||
fi
|
||||
|
||||
uci commit nut_monitor
|
||||
Reference in New Issue
Block a user