Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 38 additions & 26 deletions net/nut/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

# Copyright (C) 2006-2016 OpenWrt.org
# Copyright (C) 2006-2026 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
Expand All @@ -8,12 +8,12 @@
include $(TOPDIR)/rules.mk

PKG_NAME:=nut
PKG_VERSION:=2.8.4
PKG_RELEASE:=3
PKG_VERSION:=2.8.5
PKG_RELEASE:=2

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://networkupstools.org/source/2.8/
PKG_HASH:=a2fe55bc2d90b4a848d6ff8bac361e6d1c97f899a545219cad707d17a27ff127
PKG_SOURCE_URL:=https://www.networkupstools.org/source/2.8/
PKG_HASH:=18bf32e59eb764b13da3c4fa70384926d7fa584cb31d2fe7f137a570633eeec1
PKG_LICENSE:=GPL-2.0-or-later GPL-3.0-or-later GPL-1.0-or-later Artistic-1.0-Perl
PKG_LICENSE_FILES:=LICENSE-GPL2 LICENSE-GPL3 COPYING
PKG_FIXUP:=autoreconf
Expand Down Expand Up @@ -69,9 +69,12 @@ define Package/nut-server/install
$(INSTALL_DIR) $(1)/etc/nut
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_DIR) $(1)/lib/functions/nut
$(INSTALL_DIR) $(1)/usr/share/nut
$(INSTALL_BIN) ./files/nut-server.init $(1)/etc/init.d/nut-server
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/upsd $(1)/usr/sbin
$(INSTALL_DATA) ./files/nut-server-config.sh.functions $(1)/lib/functions/nut/nut-server-config.sh
$(INSTALL_DATA) ./files/nut-server-service.sh.functions $(1)/lib/functions/nut/nut-server-service.sh
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/upsd $(1)/usr/sbin/
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/share/nut/cmdvartab $(1)/usr/share/nut/
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_CONF) ./files/nut_server $(1)/etc/config/nut_server
Expand All @@ -84,15 +87,15 @@ define Package/nut-server/install
# Mangle libhid.usermap into a format (hotplug shell script) useful for OpenWrt
$(INSTALL_DIR) $(1)/etc/hotplug.d/usb
$(INSTALL_DIR) $(1)/etc/hotplug.d/tty
$(INSTALL_BIN) ./files/nut_serial.hotplug $(1)/etc/hotplug.d/tty/40-nut_serial
$(INSTALL_BIN) ./files/30-libhid-ups.head $(1)/etc/hotplug.d/usb/30-libhid-ups
$(CP) $(PKG_INSTALL_DIR)/etc/hotplug/usb/libhid.usermap $(PKG_BUILD_DIR)/30-libhid-ups.middle
$(INSTALL_BIN) ./files/nut-serial.hotplug $(1)/etc/hotplug.d/tty/40-nut-serial
$(CP) ./files/libhid-ups.hotplug $(PKG_BUILD_DIR)/30-libhid-ups
$(CP) $(PKG_INSTALL_DIR)/etc/hotplug/usb/libhid.usermap $(PKG_BUILD_DIR)/libhid-ups.parsed-usermap
$(SED) '/^$$$$/d' \
-e '/^#/d' \
-E -e 's:^[^ ][^ ]* *0x0003 *0x0{0,3}([^ ][^ ]*) *0x0{0,3}*([^ ][^ ]*).*:\1/\2/* | \\:' \
$(PKG_BUILD_DIR)/30-libhid-ups.middle
tail -n+2 $(PKG_BUILD_DIR)/30-libhid-ups.middle >>$(1)/etc/hotplug.d/usb/30-libhid-ups
cat ./files/30-libhid-ups.tail >>$(1)/etc/hotplug.d/usb/30-libhid-ups
$(PKG_BUILD_DIR)/libhid-ups.parsed-usermap
$(SED) 's^### insert libhid-ups.parsed-usermap content here ###^\ncat "$(PKG_BUILD_DIR)/libhid-ups.parsed-usermap"^e' $(PKG_BUILD_DIR)/30-libhid-ups
$(INSTALL_BIN) $(PKG_BUILD_DIR)/30-libhid-ups $(1)/etc/hotplug.d/usb/30-libhid-ups
endef

define Package/nut-common
Expand All @@ -117,6 +120,9 @@ endef
define Package/nut-common/install
$(INSTALL_DIR) $(1)/etc/nut
$(INSTALL_DIR) $(1)/usr/lib
$(INSTALL_DIR) $(1)/lib/functions/nut
$(INSTALL_DATA) ./files/nut-common.sh.functions $(1)/lib/functions/nut/nut-common.sh
$(INSTALL_DATA) ./files/nut-service.sh.functions $(1)/lib/functions/nut/nut-service.sh
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libupsclient.so* $(1)/usr/lib/
ln -sf /var/etc/nut/nut.conf $(1)/etc/nut/nut.conf
endef
Expand Down Expand Up @@ -170,9 +176,13 @@ define Package/nut-upsmon/install
$(INSTALL_DIR) $(1)/etc/nut
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_DIR) $(1)/lib/functions/nut
$(INSTALL_DIR) $(1)/usr/bin $(1)/etc/uci-defaults
$(INSTALL_BIN) ./files/nut-monitor.init $(1)/etc/init.d/nut-monitor
$(INSTALL_DATA) ./files/nut-monitor-config.sh.functions $(1)/lib/functions/nut/nut-monitor-config.sh
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/upsmon $(1)/usr/sbin/
$(INSTALL_BIN) ./files/nutshutdown $(1)/usr/sbin/nutshutdown
$(INSTALL_DATA) ./files/nut-monitor-migrate.default $(1)/etc/uci-defaults/80-nut-monitor-migrate
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_CONF) ./files/nut_monitor $(1)/etc/config/nut_monitor
ln -sf /var/etc/nut/upsmon.conf $(1)/etc/nut/upsmon.conf
Expand All @@ -193,7 +203,8 @@ 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
$(INSTALL_DATA) ./files/nut-sendmail-notify.default $(1)/etc/uci-defaults/81-nut-sendmail-notify
$(INSTALL_DATA) ./files/nut-notify-exec.default $(1)/etc/uci-defaults/71-nut-notify-exec
endef

define Package/nut-upsc
Expand Down Expand Up @@ -299,7 +310,8 @@ define Package/nut-upssched/install
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/upssched-cmd $(1)/usr/bin/
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/upssched $(1)/usr/sbin/
$(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/nut/upssched.conf.sample $(1)/etc/nut/upssched.conf
$(INSTALL_DATA) ./files/nut-sched.default $(1)/etc/uci-defaults/nut-upssched
$(INSTALL_DATA) ./files/nut-sched.default $(1)/etc/uci-defaults/80-nut-upssched
$(INSTALL_DATA) ./files/nut-notify-exec.default $(1)/etc/uci-defaults/70-nut-notify-exec
endef

define Package/nut-web-cgi
Expand Down Expand Up @@ -329,12 +341,9 @@ define Package/nut-web-cgi/install
$(CP) $(PKG_INSTALL_DIR)/usr/html/* $(1)/www/nut/
$(INSTALL_DIR) $(1)/etc/uci-defaults
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/cgi-bin/* $(1)/www/cgi-bin/nut
$(INSTALL_CONF) ./files/add_nut_httpd_conf $(1)/etc/uci-defaults/add_nut_httpd_conf
$(INSTALL_CONF) ./files/add_nut_httpd_conf.default $(1)/etc/uci-defaults/add_nut_httpd_conf
$(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/nut/upsstats.html.sample $(1)/etc/nut/upsstats.html
$(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/nut/upsstats-single.html.sample $(1)/etc/nut/upsstats-single.html
$(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/nut/upsset.conf.sample $(1)/etc/nut/upsset.conf.disable
$(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/nut/upsset.conf.sample $(1)/etc/nut/upsset.conf.enable
$(SED) 's/### \?//' $(1)/etc/nut/upsset.conf.enable
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_CONF) ./files/nut_cgi $(1)/etc/config/nut_cgi
$(INSTALL_DIR) $(1)/etc/init.d
Expand Down Expand Up @@ -373,7 +382,7 @@ define DriverPackage
$(if $(filter $(1),snmp),DEPENDS+= @NUT_DRIVER_SNMP)
$(if $(filter $(1),usb),DEPENDS+= @NUT_DRIVER_USB)
$(if $(filter $(1),serial),DEPENDS+= @NUT_DRIVER_SERIAL)
$(if $(filter $(1),neon),DEPENDS+= @NUT_DRIVER_NEON)
$(if $(filter $(1),neon),DEPENDS+= @NUT_DRIVER_NEON)
endef
# Deliberately empty description in order to trigger a build failure.
# It should be overridden by the list below, and when updating to a
Expand All @@ -383,9 +392,9 @@ define DriverPackage

endef
define Package/nut-driver-$(2)/install
$(INSTALL_DIR) $$(1)/lib/nut
$(CP) $$(PKG_INSTALL_DIR)/lib/nut/$(2) $$(1)/lib/nut/
$(if $(filter $(2),clone),$(CP) $$(PKG_INSTALL_DIR)/lib/nut/$(2)-outlet $$(1)/lib/nut/)
$(INSTALL_DIR) $$(1)/usr/libexec/nut
$(CP) $$(PKG_INSTALL_DIR)/usr/libexec/nut/$(2) $$(1)/usr/libexec/nut/
$(if $(filter $(2),clone),$(CP) $$(PKG_INSTALL_DIR)/usr/libexec/nut/$(2)-outlet $$(1)/usr/libexec/nut/)
endef
endef
define DriverDescription
Expand All @@ -406,7 +415,7 @@ SERIAL_DRIVERLIST = al175 bcmxcp belkin belkinunv bestfcom \
gamatronic genericups isbmex liebert liebert-esp2 liebert-gxe masterguard metasys \
mge-utalk microdowell microsol-apc mge-shut nutdrv_hashx oneac optiups powercom powervar_cx_ser rhino \
safenet nutdrv_siemens-sitop solis tripplite tripplitesu upscode2 victronups powerpanel \
blazer_ser ivtscd apcsmart apcsmart-old riello_ser sms_ser bicker_ser ve-direct \
blazer_ser ivtscd apcsmart apcsmart-old riello_ser sms_ser bicker_ser ve-direct meanwell_ntu \
nutdrv_qx
SERIAL_DRIVERLIST += nhs_ser
SNMP_DRIVERLIST = snmp-ups
Expand Down Expand Up @@ -527,8 +536,10 @@ $(eval $(call DriverDescription,serial,bicker_ser,\
Driver for Bicker DC UPS via serial port connections))
$(eval $(call DriverDescription,serial,ve-direct,\
Driver for Victron UPS unit running on VE.Direct serial protocol))
$(eval $(call DriverDescription,serial,meanwell_ntu,\
Driver for Mean Well NTU series equipment with serial port))
$(eval $(call DriverDescription,serial,nhs_ser,\
Driver for NHS Nobreaks, senoidal line, with serial port))
Driver for NHS Nobreaks - senoidal line - with serial port))
$(eval $(call DriverDescription,snmp,snmp-ups,\
Multi-MIB Driver for SNMP UPS equipment))
$(eval $(call DriverDescription,usb,usbhid-ups,\
Expand Down Expand Up @@ -556,7 +567,8 @@ CONFIGURE_VARS += \
ac_cv_path_AR=$(TARGET_AR)

CONFIGURE_ARGS += \
--sysconfdir=/etc/nut \
--sysconfdir=/etc \
--with-confdir-suffix=/nut \
--datadir=/usr/share/nut \
--with-dev \
--$(if $(CONFIG_NUT_DRIVER_USB),with,without)-usb \
Expand All @@ -579,7 +591,7 @@ CONFIGURE_ARGS += \
--without-nut_monitor \
--with-statepath=/var/run/nut \
--with-pidpath=/var/run \
--with-drvpath=/lib/nut \
--with-drvpath=/usr/libexec/nut \
--with-user=nut \
--with-group=nut \
$(if $(CONFIG_PACKAGE_nut-web-cgi),--with-gd-includes="`pkg-config --cflags gdlib`") \
Expand Down
49 changes: 0 additions & 49 deletions net/nut/files/30-libhid-ups.head

This file was deleted.

5 changes: 0 additions & 5 deletions net/nut/files/30-libhid-ups.tail

This file was deleted.

6 changes: 0 additions & 6 deletions net/nut/files/add_nut_httpd_conf

This file was deleted.

27 changes: 27 additions & 0 deletions net/nut/files/add_nut_httpd_conf.default
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh

# UCI default script to set default password to access the NUT CGI pages
# to be the system password for the root user (as with LuCI)

# $p$root is not an actual password, it is a reference to the password
# for root in the system password (/etc/shadow) password file

# In recent (relevant) versions of shellcheck busybox is a valid shell type
# shellcheck shell=busybox

# Only add this default user:password (reference) for NUT CGI if there is
# not an existing password configuration for the NUT CGI, include for other
# users.

[ -z "$IPKG_ROOT" ] || exit 0

touch /etc/httpd.conf
grep -q '^/cgi-bin/nut' /etc/httpd.conf 2>/dev/null || {
# The SC2016 shellcheck directive is required as shellcheck thinks the
# $p$root is a variable that gets expanded
# shellcheck disable=SC2016
echo '/cgi-bin/nut:root:$p$root' >>/etc/httpd.conf
if ! /etc/init.d/uhttpd restart; then
logger -s -t nut-cgi "Failed to restart uhttpd after http.conf update"
fi
Comment thread
danielfdickinson marked this conversation as resolved.
}
Loading
Loading