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)
$(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))
--- /dev/null
+#!/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