Skip to content

Commit

Permalink
Merge branch 'networkupstools:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusz-jastrzebski authored Jan 10, 2024
2 parents 73b1c2e + aeb0c3c commit 7bbdbdc
Show file tree
Hide file tree
Showing 36 changed files with 484 additions and 25 deletions.
9 changes: 9 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
# include directory for aclocal
ACLOCAL_AMFLAGS = -I m4

# Export certain values for ccache which NUT ci_build.sh can customize,
# to facilitate developer iteration re-runs of "make" later.
# At least GNU and BSD make implementations are okay with this syntax.
@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_NAMESPACE=@CCACHE_NAMESPACE@
@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_BASEDIR=@CCACHE_BASEDIR@
@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_DIR=@CCACHE_DIR@
@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_PATH=@CCACHE_PATH@
@NUT_AM_MAKE_CAN_EXPORT@export PATH=@PATH_DURING_CONFIGURE@

# subdirectories to build and distribute. The order matters, as
# several subdirectories depend on stuff in "common" or tools being built first
SUBDIRS = include common clients conf data docs drivers tools \
Expand Down
4 changes: 4 additions & 0 deletions NEWS.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ https://github.com/networkupstools/nut/milestone/10
* Added generation of FreeBSD/pfSense quirks for USB devices supported
by NUT (may get installed to `$datadir` e.g. `/usr/local/share/nut`
and need to be pasted into your `/boot/loader.conf.local`). [#2159]
* nut-scanner can now discover NUT simulated devices (.dev & .seq files)
located in your sysconfig directory
* nut-scanner now report 'dummy-ups' as driver when scanning NUT with
Old or Avahi method.

- upsd: Fixed conditions for "no listening interface available" diagnosis
to check how many listeners we succeeded with, not whether the first one
Expand Down
2 changes: 1 addition & 1 deletion ci_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ fi
echo "Processing BUILD_TYPE='${BUILD_TYPE}' ..."

echo "Build host settings:"
set | grep -E '^(PATH|.*CCACHE.*|CI_.*|OS_.*|CANBUILD_.*|NODE_LABELS|MAKE|C.*FLAGS|LDFLAGS|ARCH.*|BITS.*|CC|CXX|CPP|DO_.*|BUILD_.*)=' || true
set | grep -E '^(PATH|[^ ]*CCACHE[^ ]*|CI_[^ ]*|OS_[^ ]*|CANBUILD_[^ ]*|NODE_LABELS|MAKE|C[^ ]*FLAGS|LDFLAGS|ARCH[^ ]*|BITS[^ ]*|CC|CXX|CPP|DO_[^ ]*|BUILD_[^ ]*)=' || true
uname -a
echo "LONG_BIT:`getconf LONG_BIT` WORD_BIT:`getconf WORD_BIT`" || true
if command -v xxd >/dev/null ; then xxd -c 1 -l 6 | tail -1; else if command -v od >/dev/null; then od -N 1 -j 5 -b | head -1 ; else hexdump -s 5 -n 1 -C | head -1; fi; fi < /bin/ls 2>/dev/null | awk '($2 == 1){print "Endianness: LE"}; ($2 == 2){print "Endianness: BE"}' || true
Expand Down
9 changes: 9 additions & 0 deletions clients/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
# Network UPS Tools: clients
EXTRA_DIST =

# Export certain values for ccache which NUT ci_build.sh can customize,
# to facilitate developer iteration re-runs of "make" later.
# At least GNU and BSD make implementations are okay with this syntax.
@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_NAMESPACE=@CCACHE_NAMESPACE@
@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_BASEDIR=@CCACHE_BASEDIR@
@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_DIR=@CCACHE_DIR@
@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_PATH=@CCACHE_PATH@
@NUT_AM_MAKE_CAN_EXPORT@export PATH=@PATH_DURING_CONFIGURE@

# nutclient.cpp for some legacy reason (maybe initial detached development?)
# optionally includes "common.h" with the NUT build setup - and this option
# was never triggered in fact, not until pushed through command line like this:
Expand Down
9 changes: 9 additions & 0 deletions common/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ EXTRA_DIST =
noinst_LTLIBRARIES = libparseconf.la libcommon.la libcommonclient.la
libparseconf_la_SOURCES = parseconf.c

# Export certain values for ccache which NUT ci_build.sh can customize,
# to facilitate developer iteration re-runs of "make" later.
# At least GNU and BSD make implementations are okay with this syntax.
@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_NAMESPACE=@CCACHE_NAMESPACE@
@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_BASEDIR=@CCACHE_BASEDIR@
@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_DIR=@CCACHE_DIR@
@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_PATH=@CCACHE_PATH@
@NUT_AM_MAKE_CAN_EXPORT@export PATH=@PATH_DURING_CONFIGURE@

# do not hard depend on '../include/nut_version.h', since it blocks
# 'dist', and is only required for actual build, in which case
# BUILT_SOURCES (in ../include) will ensure nut_version.h will
Expand Down
68 changes: 68 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,20 @@ dnl Use "./configure --enable-maintainer-mode" to keep Makefile.in and Makefile
dnl in sync after Git updates.
AM_MAINTAINER_MODE

dnl GNU and BSD make are okay with the syntax, but Sun make/dmake are not:
AC_MSG_CHECKING([whether this make implementation supports export VAR=VAL syntax])
dnl # using printf formatting for some funniner shells out there
nut_am_output="`printf 'export VAR=VAL\ntest:\n\t@echo "VAR=%s%sVAR%s"\n' '\$' '(' ')' | ${MAKE-make} -f - test`"
nut_am_result="$?"
AS_IF([test x"${nut_am_result}" = x0 -a x"${nut_am_output}" = x"VAR=VAL"], [
NUT_AM_MAKE_CAN_EXPORT=""
AC_MSG_RESULT(yes)
], [
NUT_AM_MAKE_CAN_EXPORT="#ThisMakeCanNotExport# "
AC_MSG_RESULT(no: got '${nut_am_output}')
])
AC_SUBST(NUT_AM_MAKE_CAN_EXPORT)

dnl Some systems have older autotools without direct macro support for PKG_CONF*
NUT_CHECK_PKGCONFIG

Expand Down Expand Up @@ -4575,6 +4589,60 @@ EOF])
])
AC_MSG_RESULT([done])

dnl # ccache versions 4.5 and newer support namespacing of the objects
dnl # to facilitate more targeted eviction with --evict-namespace and
dnl # perhaps --evict-older-than options. Here we bolt a namespace with
dnl # NUT as the project and CPU architecture for resulting binaries;
dnl # maybe we might use distro as well but some overlaps may be possible
dnl # that result in same objects for different-looking build roots.
dnl # Note this is enabled by default (explicit --without-... disables it).
dnl # Has practical effect if NUT_AM_MAKE_CAN_EXPORT test is successful.
AS_IF([test x"${CCACHE_NAMESPACE}" = x], [
CCACHE_NAMESPACE="nut"
dnl # Variables in this list are defined earlier in the script
for T in "${compiler_multiarch}" "${target_alias}" "${target}" "${target_cpu}-${target_os}" ; do
if test x"$T" != x -a x"$T" != x- ; then
CCACHE_NAMESPACE="${CCACHE_NAMESPACE}:${T}"
break
fi
done
unset T
])
AC_ARG_WITH(CCACHE_NAMESPACE,
AS_HELP_STRING([--with-CCACHE_NAMESPACE=namespace], [which ccache namespace to use for built binaries; typically nut:${autotools_target})]),
[
case "${withval}" in
no)
CCACHE_NAMESPACE=""
;;
yes) # Use user envvar or calculation above
;;
*)
CCACHE_NAMESPACE="${withval}"
;;
esac
], [])
NUT_REPORT_TARGET(CCACHE_NAMESPACE, "${CCACHE_NAMESPACE}", [ccache namespace tag (if ccache is used and new enough)])
AS_IF([test x"$CCACHE_NAMESPACE" != x -a x"$NUT_AM_MAKE_CAN_EXPORT" != x], [
AC_MSG_WARN([CCACHE_NAMESPACE setting may have no effect: this make implementation seems to not support "export VAR=VAL" syntax])
])

dnl # Mark it as a "precious variable", for more details see
dnl # https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Setting-Output-Variables.html
AC_ARG_VAR(CCACHE_NAMESPACE)

dnl # Also list some other ccache options which ci_build.sh can fiddle with.
dnl # While that script "exports" them so it can call both configuration and
dnl # the build, their values may be unknown when a developer re-runs "make".
dnl # Normally most of the options would persist under $CCACHE_DIR/ccache.conf
dnl # and we would not pass them via envvars.
AC_ARG_VAR(CCACHE_BASEDIR)
AC_ARG_VAR(CCACHE_DIR)
AC_ARG_VAR(CCACHE_PATH)

PATH_DURING_CONFIGURE="$PATH"
AC_SUBST(PATH_DURING_CONFIGURE)

AC_MSG_NOTICE([Generating "data" files from templates, see below for executable scripts])
AC_CONFIG_FILES([
clients/Makefile
Expand Down
3 changes: 3 additions & 0 deletions data/driver.list.in
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,9 @@
"Numeric" "ups" "2" "3000 SW" "" "blazer_ser"
"Numeric" "ups" "2" "Digital 800 plus" "USB" "nutdrv_qx or blazer_usb"

"NUT" "ups" "5" "all supported NUT devices, through remote upsd" "" "dummy-ups"
"NUT" "ups" "5" "Simulated devices" "" "dummy-ups"

"Oneac" "ups" "1" "ON400" "advanced interface" "oneac"
"Oneac" "ups" "1" "ON600" "advanced interface" "oneac"
"Oneac" "ups" "1" "ON900" "advanced interface" "oneac"
Expand Down
2 changes: 2 additions & 0 deletions docs/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Network UPS Tools: main docs

MAINTAINERCLEANFILES = Makefile.in .dirstamp
EXTRA_DIST =

Expand Down
2 changes: 2 additions & 0 deletions docs/cables/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# Network UPS Tools: cable docs

CLEANFILES = *-spellchecked
MAINTAINERCLEANFILES = Makefile.in .dirstamp
3 changes: 3 additions & 0 deletions docs/ci-farm-lxc-setup.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ Common preparations
pairs, one per line (so one per container)
*** `systemctl restart lxc-net` to apply config (is this needed after
setup of containers too, to apply new items before booting them?)
*** For troubleshooting, see `/var/lib/misc/dnsmasq.lxcbr0.leases`
(in some cases you may have to rename it away and reboot host to
fix IP address delegation)

* Install qemu with its `/usr/bin/qemu-*-static` and registration in
`/var/lib/binfmt`
Expand Down
11 changes: 11 additions & 0 deletions docs/developer-guide.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,17 @@ Here is an example to setup a device simulation:

For more information, refer to linkman:dummy-ups[8] manual page.

[[dev-simu-disco]]

Simulated devices discovery
---------------------------

Any simulation file that is saved in the sysconfig directory can be
automatically discovered and configured using nut-scanner:
+
$ nut-scanner -n
$ nut-scanner --nut_simulation_scan
+

[[dev-recording]]

Expand Down
5 changes: 4 additions & 1 deletion docs/man/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Network UPS Tools: man
# Network UPS Tools: man pages
#

# Notes:
Expand Down Expand Up @@ -174,6 +174,7 @@ SRC_DEV_PAGES = \
nutscan_scan_usb.txt \
nutscan_scan_xml_http_range.txt \
nutscan_scan_nut.txt \
nutscan_scan_nut_simulation.txt \
nutscan_scan_avahi.txt \
nutscan_scan_ipmi.txt \
nutscan_scan_eaton_serial.txt \
Expand Down Expand Up @@ -291,6 +292,7 @@ MAN3_DEV_PAGES = \
nutscan_scan_usb.3 \
nutscan_scan_xml_http_range.3 \
nutscan_scan_nut.3 \
nutscan_scan_nut_simulation.3 \
nutscan_scan_avahi.3 \
nutscan_scan_ipmi.3 \
nutscan_scan_eaton_serial.3 \
Expand Down Expand Up @@ -360,6 +362,7 @@ HTML_DEV_MANS = \
nutscan_scan_usb.html \
nutscan_scan_xml_http_range.html \
nutscan_scan_nut.html \
nutscan_scan_nut_simulation.html \
nutscan_scan_avahi.html \
nutscan_scan_ipmi.html \
nutscan_scan_eaton_serial.html \
Expand Down
28 changes: 27 additions & 1 deletion docs/man/nut-scanner.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ DESCRIPTION
*nut-scanner* scans available communication buses and displays any
NUT-compatible devices it has found.

*nut-scanner* can also display the detected devices in various formats,
including ups.conf, and ensures that the generated devices name are unique
across buses.

INSTALLATION
------------

Expand Down Expand Up @@ -67,6 +71,9 @@ interfaces to retrieve XML/HTTP capable devices. No IP required in this mode.
*-O* | *--oldnut_scan*::
Scan NUT devices (i.e. upsd daemon) on IP ranging from 'start IP' to 'end IP'.

*-n* | *--nut_simulation_scan*::
Scan NUT simulated devices (.dev files in $CONFPATH).

*-A* | *--avahi_scan*::
Scan NUT servers using Avahi request on the current network interfaces.
No IP required.
Expand All @@ -88,7 +95,6 @@ ports using 'X-Y', where X and Y are characters referring to the port number.
- a single port name.
- a list of ports name, coma separated, like '/dev/ttyS1,/dev/ttyS4'.


NETWORK OPTIONS
---------------

Expand Down Expand Up @@ -217,20 +223,40 @@ EXAMPLES
To scan USB devices only:

*nut-scanner -U*
+
[nutdev-usb1]
driver = "snmp-ups"
port = "192.168.0.42"
+

To scan SNMP v1 device with public community on address range 192.168.0.0
to 192.168.0.255:

*nut-scanner -S -s 192.168.0.0 -e 192.168.0.255*
+
[nutdev-snmp1]
driver = "snmp-ups"
port = "192.168.0.42"
+

The same using CIDR notation:

*nut-scanner -S -m 192.168.0.0/24*
+
[nutdev-snmp1]
driver = "snmp-ups"
port = "192.168.0.42"
+

To scan NUT servers with a timeout of 10 seconds on IP range 192.168.0.0
to 192.168.0.127 using CIDR notation:

*nut-scanner -O -t 10 -m 192.168.0.0/25*
+
[nutdev-nut1]
driver = "dummy-ups"
port = "dummy-test@192.168.1.28"
+

To scan for power supplies, through IPMI (1.5 mode) over the network,
on address range 192.168.0.0 to 192.168.0.255 using CIDR notation:
Expand Down
7 changes: 4 additions & 3 deletions docs/man/nutscan_init.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ This depends on the libraries installed on the system:
nutscan_avail_avahi = 1 : AVAHI scan is available
nutscan_avail_ipmi = 1 : IPMI scan is available
nutscan_avail_nut = 1 : Old NUT method is available
nutscan_avail_nut_simulation = 1 : NUT simulation devices method is available
nutscan_avail_snmp = 1 : SNMP method is available
nutscan_avail_usb = 1 : USB method is available
nutscan_avail_xml_http = 1 : XML HTTP method is available
Expand All @@ -44,9 +45,9 @@ SEE ALSO

linkman:nutscan_init[3], linkman:nutscan_scan_usb[3],
linkman:nutscan_scan_snmp[3], linkman:nutscan_scan_xml_http_range[3],
linkman:nutscan_scan_nut[3], linkman:nutscan_scan_avahi[3],
linkman:nutscan_scan_ipmi[3], linkman:nutscan_display_ups_conf[3],
linkman:nutscan_display_sanity_check[3],
linkman:nutscan_scan_nut[3], linkman:nutscan_scan_nut_simulation[3],
linkman:nutscan_scan_avahi[3], linkman:nutscan_scan_ipmi[3],
linkman:nutscan_display_ups_conf[3], linkman:nutscan_display_sanity_check[3],
linkman:nutscan_display_sanity_check_serial[3],
linkman:nutscan_display_ups_conf_with_sanity_check[3],
linkman:nutscan_display_parsable[3], linkman:nutscan_new_device[3],
Expand Down
47 changes: 47 additions & 0 deletions docs/man/nutscan_scan_nut_simulation.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
NUTSCAN_SCAN_NUT_SIMULATION(3)
==============================

NAME
----

nutscan_scan_nut_simulation - Scan your sysconfig directory for NUT simulation devices.

SYNOPSIS
--------

#include <nut-scan.h>
#include <unistd.h> /* useconds_t */

nutscan_device_t * nutscan_scan_nut_simulation();

DESCRIPTION
-----------

The *nutscan_scan_nut_simulation()* function try to detect available NUT
simulation devices, by finding .dev and .seq files in your sysconfig
directory.

You MUST call linkman:nutscan_init[3] before using this function.

RETURN VALUE
------------

The *nutscan_scan_nut_simulation()* function returns a pointer to a
`nutscan_device_t` structure containing all found devices or NULL if an
error occurs or no device is found.

SEE ALSO
--------

linkman:nutscan_init[3],
linkman:nutscan_scan_usb[3], linkman:nutscan_scan_xml_http_range[3],
linkman:nutscan_scan_snmp[3], linkman:nutscan_scan_avahi[3],
linkman:nutscan_scan_ipmi[3], linkman:nutscan_scan_nut[3],
linkman:nutscan_display_sanity_check[3],
linkman:nutscan_display_sanity_check_serial[3],
linkman:nutscan_display_ups_conf_with_sanity_check[3],
linkman:nutscan_display_ups_conf[3],
linkman:nutscan_display_parsable[3], linkman:nutscan_new_device[3],
linkman:nutscan_free_device[3], linkman:nutscan_add_option_to_device[3],
linkman:nutscan_add_device_to_device[3], linkman:nutscan_scan_eaton_serial[3],
linkman:nutscan_cidr_to_ip[3]
9 changes: 9 additions & 0 deletions drivers/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Network UPS Tools: drivers

# Export certain values for ccache which NUT ci_build.sh can customize,
# to facilitate developer iteration re-runs of "make" later.
# At least GNU and BSD make implementations are okay with this syntax.
@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_NAMESPACE=@CCACHE_NAMESPACE@
@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_BASEDIR=@CCACHE_BASEDIR@
@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_DIR=@CCACHE_DIR@
@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_PATH=@CCACHE_PATH@
@NUT_AM_MAKE_CAN_EXPORT@export PATH=@PATH_DURING_CONFIGURE@

# Make sure out-of-dir dependencies exist (especially when dev-building parts):
$(top_builddir)/common/libcommon.la \
$(top_builddir)/common/libparseconf.la \
Expand Down
11 changes: 11 additions & 0 deletions include/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# Network UPS Tools: include

# Export certain values for ccache which NUT ci_build.sh can customize,
# to facilitate developer iteration re-runs of "make" later.
# At least GNU and BSD make implementations are okay with this syntax.
@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_NAMESPACE=@CCACHE_NAMESPACE@
@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_BASEDIR=@CCACHE_BASEDIR@
@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_DIR=@CCACHE_DIR@
@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_PATH=@CCACHE_PATH@
@NUT_AM_MAKE_CAN_EXPORT@export PATH=@PATH_DURING_CONFIGURE@

dist_noinst_HEADERS = attribute.h common.h extstate.h proto.h \
state.h str.h timehead.h upsconf.h nut_float.h nut_stdint.h nut_platform.h \
wincompat.h
Expand Down
Loading

0 comments on commit 7bbdbdc

Please sign in to comment.