net/nut: Build optional separate packages and ucify

With a LuCI app (of which I have one written) ucification makes
sense (and is in fact needed), so ucify the initscripts.

Also, rather than making selection of things to include an image
a matter of selecting compile-time config options, make optional
things into seperate packages that are built in default builds,
and leave selection of what to include or not up to the user
(e.g. using ImageBuilder, or adding packages via opkg).

Signed-off-by: Daniel Dickinson <lede@cshore.thecshore.com>
This commit is contained in:
Daniel Dickinson
2017-01-11 18:53:58 -05:00
parent 80f93e5513
commit a23c4e85c5
10 changed files with 656 additions and 157 deletions
+227 -67
View File
@@ -1,5 +1,5 @@
#
# Copyright (C) 2006-2015 OpenWrt.org
# Copyright (C) 2006-2016 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
@@ -18,19 +18,12 @@ PKG_MAINTAINER:=Martin Rowe <martin.p.rowe@gmail.com>
PKG_LICENSE:=GPL-2.0
PKG_LICENSE_FILES:=LICENSE-GPL2
PKG_BUILD_DIR:=$(BUILD_DIR)/nut-$(PKG_VERSION)
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_INSTALL:=1
PKG_CONFIG_DEPENDS:= \
CONFIG_NUT_CLIENTS_UPSC \
CONFIG_NUT_CLIENTS_UPSCMD \
CONFIG_NUT_CLIENTS_UPSLOG \
CONFIG_NUT_CLIENTS_UPSMON \
CONFIG_NUT_CLIENTS_UPSRW \
CONFIG_NUT_CLIENTS_UPSSCHED \
CONFIG_NUT_DRIVER_SNMP \
CONFIG_NUT_DRIVER_USB \
CONFIG_NUT_SERVER \
CONFIG_NUT_SSL
include $(INCLUDE_DIR)/package.mk
@@ -39,10 +32,10 @@ define Package/nut/Default
SECTION:=net
CATEGORY:=Network
URL:=http://www.networkupstools.org/
DEPENDS:=nut
TITLE:=Network UPS Tools (NUT)
endef
define Package/nut/description
define Package/nut/description/Default
Network UPS Tools (NUT) is a client/server monitoring system that
allows computers to share uninterruptible power supply (UPS) and
power distribution unit (PDU) hardware. Clients access the hardware
@@ -52,68 +45,222 @@ endef
define Package/nut
$(call Package/nut/Default)
TITLE:=Network UPS Tools
DEPENDS:= \
+libpthread \
+NUT_DRIVER_SNMP:libnetsnmp \
+NUT_DRIVER_USB:libusb-compat \
+NUT_SSL:libopenssl
MENU:=1
endef
define Package/nut/description
$(call Package/nut/description/Default)
endef
define Package/nut/config
source "$(SOURCE)/Config.in"
endef
define Package/nut/conffiles
/etc/nut/nut.conf
$(if $(CONFIG_NUT_CLIENTS_UPSMON),/etc/nut/upsmon.conf)
$(if $(CONFIG_NUT_CLIENTS_UPSSCHED),/etc/nut/upssched.conf)
$(if $(CONFIG_NUT_SERVER),/etc/nut/ups.conf)
$(if $(CONFIG_NUT_SERVER),/etc/nut/upsd.conf)
$(if $(CONFIG_NUT_SERVER),/etc/nut/upsd.users)
define Package/nut/install
true
endef
define Package/nut/install
define Package/nut-server/install
$(INSTALL_DIR) $(1)/etc/nut
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_DIR) $(1)/usr/lib
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/nut/nut.conf.sample $(1)/etc/nut/nut.conf
$(if $(or $(CONFIG_NUT_CLIENTS_UPSC),\
$(CONFIG_NUT_CLIENTS_UPSCMD),\
$(CONFIG_NUT_CLIENTS_LOG),\
$(CONFIG_NUT_CLIENTS_UPSRW),\
$(CONFIG_NUT_CLIENTS_UPSMON),\
$(CONFIG_NUT_CLIENTS_UPSSCHED)),$(CP) $(PKG_INSTALL_DIR)/usr/lib/libupsclient.so* $(1)/usr/lib/)
$(if $(or $(CONFIG_NUT_SERVER),\
$(CONFIG_NUT_CLIENTS_UPSMON)),$(INSTALL_DIR) $(1)/etc/init.d)
$(if $(CONFIG_NUT_SERVER),$(INSTALL_DIR) $(1)/lib/nut)
$(if $(CONFIG_NUT_SERVER),$(INSTALL_DIR) $(1)/usr/share/nut)
$(if $(CONFIG_NUT_SERVER),$(CP) ./files/nut-server.init $(1)/etc/init.d/)
$(if $(CONFIG_NUT_SERVER),$(CP) $(PKG_INSTALL_DIR)/usr/sbin/upsd $(1)/usr/sbin)
$(if $(CONFIG_NUT_SERVER),$(CP) $(PKG_INSTALL_DIR)/usr/sbin/upsdrvctl $(1)/usr/sbin)
$(if $(CONFIG_NUT_SERVER),$(CP) $(PKG_INSTALL_DIR)/usr/share/nut/cmdvartab $(1)/usr/share/nut/)
$(if $(CONFIG_NUT_SERVER),$(CP) $(PKG_INSTALL_DIR)/usr/share/nut/driver.list $(1)/usr/share/nut/)
$(if $(CONFIG_NUT_SERVER),$(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/nut/ups.conf.sample $(1)/etc/nut/ups.conf)
$(if $(CONFIG_NUT_SERVER),$(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/nut/upsd.conf.sample $(1)/etc/nut/upsd.conf)
$(if $(CONFIG_NUT_SERVER),$(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/nut/upsd.users.sample $(1)/etc/nut/upsd.users)
$(if $(CONFIG_NUT_CLIENTS_UPSC),$(CP) $(PKG_INSTALL_DIR)/usr/bin/upsc $(1)/usr/bin/)
$(if $(CONFIG_NUT_CLIENTS_UPSCMD),$(CP) $(PKG_INSTALL_DIR)/usr/bin/upscmd $(1)/usr/bin/)
$(if $(CONFIG_NUT_CLIENTS_UPSLOG),$(CP) $(PKG_INSTALL_DIR)/usr/bin/upslog $(1)/usr/bin/)
$(if $(CONFIG_NUT_CLIENTS_UPSRW),$(CP) $(PKG_INSTALL_DIR)/usr/bin/upsrw $(1)/usr/bin/)
$(if $(CONFIG_NUT_CLIENTS_UPSMON),$(CP) ./files/nut-monitor.init $(1)/etc/init.d/)
$(if $(CONFIG_NUT_CLIENTS_UPSMON),$(CP) $(PKG_INSTALL_DIR)/usr/sbin/upsmon $(1)/usr/sbin/)
$(if $(CONFIG_NUT_CLIENTS_UPSMON),$(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/nut/upsmon.conf.sample $(1)/etc/nut/upsmon.conf)
$(if $(CONFIG_NUT_CLIENTS_UPSSCHED),$(CP) $(PKG_INSTALL_DIR)/usr/bin/upssched-cmd $(1)/usr/bin/)
$(if $(CONFIG_NUT_CLIENTS_UPSSCHED),$(CP) $(PKG_INSTALL_DIR)/usr/sbin/upssched $(1)/usr/sbin/)
$(if $(CONFIG_NUT_CLIENTS_UPSSCHED),$(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/nut/upssched.conf.sample $(1)/etc/nut/upssched.conf)
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_DIR) $(1)/usr/share/nut
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/nut-server.init $(1)/etc/init.d/nut-server
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/upsd $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/upsdrvctl $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/share/nut/cmdvartab $(1)/usr/share/nut/
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/share/nut/driver.list $(1)/usr/share/nut/
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_CONF) ./files/nut_server $(1)/etc/config/nut_server
ln -sf /var/etc/nut/nut.conf $(1)/etc/nut/nut.conf
ln -sf /var/etc/nut/ups.conf $(1)/etc/nut/ups.conf
ln -sf /var/etc/nut/upsd.users $(1)/etc/nut/upsd.users
ln -sf /var/etc/nut/upsd.conf $(1)/etc/nut/upsd.conf
endef
define Package/nut-common
$(call Package/nut/Default)
TITLE+= (common)
DEPENDS:= nut \
+NUT_DRIVER_SNMP:libnetsnmp \
+NUT_DRIVER_USB:libusb-compat \
+NUT_SSL:libopenssl
endef
define Package/nut-common/description
$(call Package/nut/description/Default)
This package contains the common files.
endef
define Package/nut-common/install
$(INSTALL_DIR) $(1)/etc/nut
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libupsclient.so* $(1)/usr/lib/
ln -sf /var/etc/nut/nut.conf $(1)/etc/nut/nut.conf
endef
define Package/nut-server
$(call Package/nut/Default)
TITLE+= (server)
DEPENDS:=nut +nut-common
endef
define Package/nut-server/description
$(call Package/nut/description/Default)
upsd is responsible for serving the data from the drivers to the
clients. It connects to each driver and maintains a local cache of the
current state. Queries from the clients are served from this cache, so
delays are minimal. This program is essential, and must be running at
all times to actually make any use out of the drivers and clients.
endef
define Package/nut-server/conffiles
/etc/config/nut_server
endef
define Package/nut-upsmon
$(call Package/nut/Default)
TITLE+= (monitor)
DEPENDS:=nut +nut-common
USERID:=nut=113:nut=113
endef
define Package/nut-upsmon/description
$(call Package/nut/description/Default)
upsmon is the client process that is responsible for the most important
part of UPS monitoring--shutting down the system when the power goes
out. It can call out to other helper programs for notification purposes
during power events. upsmon can monitor multiple systems using a single
process. Every UPS that is defined in the upsmon.conf configuration file
is assigned a power value and a type (slave or master).
endef
define Package/nut-upsmon/conffiles
/etc/config/nut_monitor
endef
define Package/nut-upsmon/install
$(INSTALL_DIR) $(1)/etc/nut
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/nut-monitor.init $(1)/etc/init.d/nut-monitor
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/upsmon $(1)/usr/sbin/
$(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
endef
define Package/nut-upsc
$(call Package/nut/Default)
TITLE+= (upsc command)
DEPENDS:=nut +nut-common
endef
define Package/nut-upsc/description
$(call Package/nut/description/Default)
upsc is provided as a quick way to poll the status of a UPS server. It
can be used inside shell scripts and other programs that need UPS data
but don not want to include the full interface.
endef
define Package/nut-upsc/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/upsc $(1)/usr/bin
endef
define Package/nut-upslog
$(call Package/nut/Default)
TITLE+= (logging client)
DEPENDS:=nut +nut-common
endef
define Package/nut-upslog/description
$(call Package/nut/description/Default)
upslog is a daemon that will poll a UPS at periodic intervals, fetch the
variables that interest you, format them, and write them to a file.
endef
define Package/nut-upslog/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/upslog $(1)/usr/bin/
endef
define Package/nut-upscmd
$(call Package/nut/Default)
TITLE+= (controller)
DEPENDS:=nut +nut-common
endef
define Package/nut-upscmd/description
$(call Package/nut/description/Default)
upscmd allows you to invoke "instant commands" in your UPS hardware. Not
all hardware supports this, so check the list with -l to see if anything
will work on your equipment. On hardware that supports it, you can use
this program to start and stop battery tests, invoke a front panel test
(beep!), turn the load on or off, and more.
endef
define Package/nut-upscmd/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/upscmd $(1)/usr/bin/
endef
define Package/nut-upsrw
$(call Package/nut/Default)
TITLE+= (variable editor)
DEPENDS:=nut +nut-common
endef
define Package/nut-upsrw/description
$(call Package/nut/description/Default)
upsrw allows you to view and change the read/write variables inside your
UPS. It sends commands via the upsd to your driver, which configures the
hardware for you. The list of variables that allow you to change their
values is based on the capabilities of your UPS equipment. Not all
models support this feature. Typically, cheaper hardware does not
support any of them.
endef
define Package/nut-upsrw/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/upsrw $(1)/usr/bin/
endef
define Package/nut-upssched
$(call Package/nut/Default)
TITLE+= (helper for triggering events from upsmon)
DEPENDS:=nut +nut-common +nut-upsmon
endef
define Package/nut-upssched/description
$(call Package/nut/description/Default)
upssched was created to allow users to execute programs at times relative
to events being monitored by upsmon. The original purpose was to allow
for a shutdown to occur after some fixed period on battery, but there are
other uses that are possible.
You can alternatively write your own script and save some space.
endef
define Package/nut-upssched/conffiles
/etc/nut/upssched.conf
endef
define Package/nut-upssched/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_DIR) $(1)/etc/nut
$(INSTALL_DIR) $(1)/etc/uci-defaults
$(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
endef
define Package/nut-web-cgi
$(call Package/nut/Default)
TITLE+= Web CGI interface
DEPENDS+=+libgd
DEPENDS:=nut +nut-common +libgd
endef
define Package/nut-web-cgi/description
@@ -127,23 +274,29 @@ define Package/nut-web-cgi/conffiles
/etc/nut/upsset.conf
/etc/nut/upsstats.html
/etc/nut/upsstats-single.html
/etc/config/nut_cgi
endef
define Package/nut-web-cgi/install
$(INSTALL_DIR) $(1)/www/cgi-bin/nut $(1)/www/nut
$(INSTALL_DIR) $(1)/etc/nut
$(INSTALL_DIR) $(1)/usr/share/www/cgi-bin
$(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/nut/hosts.conf.sample $(1)/etc/nut/hosts.conf
$(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/nut/upsset.conf.sample $(1)/etc/nut/upsset.conf
$(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) $(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
$(CP) $(PKG_INSTALL_DIR)/usr/share/www/nut $(1)/usr/share/www/
$(CP) $(PKG_INSTALL_DIR)/usr/share/www/cgi-bin/nut $(1)/usr/share/www/cgi-bin/
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_CONF) ./files/nut_cgi $(1)/etc/config/nut_cgi
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/nut-cgi.init $(1)/etc/init.d/nut-cgi
ln -sf /var/etc/nut/hosts.conf $(1)/etc/nut/hosts.conf
endef
define Package/nut-avahi-service
$(call Package/nut/Default)
TITLE+= (Avahi service)
DEPENDS+=+avahi-daemon
DEPENDS:=nut +avahi-daemon
endef
define Package/nut-avahi-service/description
@@ -166,6 +319,7 @@ define DriverPackage
define Package/nut-driver-$(2)
$(call Package/nut/Default)
TITLE:=$(2) (NUT $(1) driver)
DEPENDS:=nut +nut-common
$(if $(filter $(1),snmp),DEPENDS+= @NUT_DRIVER_SNMP)
$(if $(filter $(1),usb),DEPENDS+= @NUT_DRIVER_USB)
endef
@@ -325,15 +479,13 @@ CONFIGURE_ARGS += \
--$(if $(CONFIG_NUT_DRIVER_SNMP),with,without)-snmp \
--without-neon \
--without-powerman \
--with-cgi \
--without-ipmi \
--without-freeipmi \
--$(if $(CONFIG_NUT_SSL),with,without)-ssl $(if $(CONFIG_NUT_SSL),--with-openssl) \
--without-libltdl \
--$(if $(CONFIG_PACKAGE_nut-web-cgi),with,without)-cgi \
--with-statepath=/var/run \
--with-drvpath=/lib/nut \
--with-cgipath=/usr/share/www/cgi-bin/nut \
--with-htmlpath=/usr/share/www/nut \
--with-user=root \
--with-group=root
@@ -345,6 +497,14 @@ define Build/InstallDev
endef
$(eval $(call BuildPackage,nut))
$(eval $(call BuildPackage,nut-common))
$(eval $(call BuildPackage,nut-server))
$(eval $(call BuildPackage,nut-upsmon))
$(eval $(call BuildPackage,nut-upsc))
$(eval $(call BuildPackage,nut-upscmd))
$(eval $(call BuildPackage,nut-upslog))
$(eval $(call BuildPackage,nut-upsrw))
$(eval $(call BuildPackage,nut-upssched))
$(eval $(call BuildPackage,nut-web-cgi))
$(eval $(call BuildPackage,nut-avahi-service))
$(foreach d,$(filter-out $(SERIAL_DRIVERLIST_IGNORE),$(SERIAL_DRIVERLIST)),$(eval $(call BuildPackage,nut-driver-$(d))))