lede-packages-rs

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

commit c94e334c4e5251d09995e3f6c8b80d61928a451c
parent 5503dac80676b858f81855610170796247a86830
Author: Daniel Dickinson <lede@cshore.thecshore.com>
Date:   Wed, 11 Jan 2017 18:54:40 -0500

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>

Diffstat:
Mnet/nut/Makefile | 19+++++++++++++++++++
Anet/nut/files/nut-sendmail-notify | 10++++++++++
Anet/nut/files/nut-sendmail-notify.default | 44++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 73 insertions(+), 0 deletions(-)

diff --git a/net/nut/Makefile b/net/nut/Makefile @@ -152,6 +152,24 @@ define Package/nut-upsmon/install ln -sf /var/etc/nut/upsmon.conf $(1)/etc/nut/upsmon.conf endef +define Package/nut-upsmon-sendmail-notify + $(call Package/nut/Default) + TITLE+= (upsmon with notifications via sendmail) + DEPENDS:=nut +nut-upsmon + CONFLICTS:=nut-upssched +endef + +define Package/nut-upsmon-sendmail-notify/description +$(call Package/nut/description/Default) +upsmon with default notification via sendmail +endef + +define Package/nut-upsmon-sendmail-notify/install + $(INSTALL_DIR) $(1)/usr/bin $(1)/etc/uci-defaults + $(INSTALL_BIN) ./files/nut-sendmail-notify $(1)/usr/bin/ + $(INSTALL_DATA) ./files/nut-sendmail-notify.default $(1)/etc/uci-defaults/nut-sendmail-notify +endef + define Package/nut-upsc $(call Package/nut/Default) TITLE+= (upsc command) @@ -504,6 +522,7 @@ $(eval $(call BuildPackage,nut)) $(eval $(call BuildPackage,nut-common)) $(eval $(call BuildPackage,nut-server)) $(eval $(call BuildPackage,nut-upsmon)) +$(eval $(call BuildPackage,nut-upsmon-sendmail-notify)) $(eval $(call BuildPackage,nut-upsc)) $(eval $(call BuildPackage,nut-upscmd)) $(eval $(call BuildPackage,nut-upslog)) diff --git a/net/nut/files/nut-sendmail-notify b/net/nut/files/nut-sendmail-notify @@ -0,0 +1,10 @@ +#!/bin/sh + +/usr/sbin/sendmail root <<EOF +From: root +To: root +Subject: UPS $NOTIFYTYPE Notification + +$1 +. +EOF diff --git a/net/nut/files/nut-sendmail-notify.default b/net/nut/files/nut-sendmail-notify.default @@ -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