From dc2332d2a63c68464235db5389d29e02bb79f796 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 2 Jan 2025 16:52:38 +0100 Subject: [PATCH 01/11] Introduce service wrapping for upslog client daemon [#1803] Signed-off-by: Jim Klimov --- configure.ac | 18 +++- scripts/Solaris/.gitignore | 2 + scripts/Solaris/Makefile.am | 2 + scripts/Solaris/nut-logger.xml.in | 127 ++++++++++++++++++++++++++ scripts/Solaris/svc-nut-logger.in | 75 +++++++++++++++ scripts/systemd/.gitignore | 1 + scripts/systemd/Makefile.am | 3 +- scripts/systemd/nut-logger.service.in | 59 ++++++++++++ scripts/systemd/nut.target.in | 3 +- 9 files changed, 287 insertions(+), 3 deletions(-) create mode 100644 scripts/Solaris/nut-logger.xml.in create mode 100755 scripts/Solaris/svc-nut-logger.in create mode 100644 scripts/systemd/nut-logger.service.in diff --git a/configure.ac b/configure.ac index ffcfd9d480..73318fbd7f 100644 --- a/configure.ac +++ b/configure.ac @@ -4130,6 +4130,8 @@ AS_IF([test x"${with_libsystemd}" = xyes && test x"${SYSTEMD_SUPPORTS_DAEMON_TYP dnl needed for `upsd -c reload` in legacy scripts and old habits to work: SYSTEMD_DAEMON_ARGS_UPSD="-FF" SYSTEMD_DAEMON_TYPE_UPSD="notify" + SYSTEMD_DAEMON_ARGS_UPSLOG="-F" + SYSTEMD_DAEMON_TYPE_UPSLOG="notify" SYSTEMD_DAEMON_ARGS_UPSMON="-F" SYSTEMD_DAEMON_TYPE_UPSMON="notify" SYSTEMD_DAEMON_ARGS_DRIVER="-FF" @@ -4146,29 +4148,36 @@ AS_IF([test x"${with_libsystemd}" = xyes && test x"${SYSTEMD_SUPPORTS_DAEMON_TYP SYSTEMD_DAEMON_NOTIFYACCESS_DRIVER="NotifyAccess=all" dnl Similar for UPSMON with its two processes: SYSTEMD_DAEMON_NOTIFYACCESS_UPSMON="NotifyAccess=all" - dnl UPSD is started directly by systemd and do not fork: + dnl UPSD is started directly by systemd and does not fork: SYSTEMD_DAEMON_NOTIFYACCESS_UPSD="NotifyAccess=main" + dnl Similarly for upslog (per settings above): + SYSTEMD_DAEMON_NOTIFYACCESS_UPSLOG="NotifyAccess=main" dnl Note: at this time we do not pre-define watchdog settings, dnl to avoid breaking something by a poorly hardcoded guess. dnl This is something end-users should do for their deployment, dnl especially for drivers SYSTEMD_DAEMON_WATCHDOG_DRIVER="#WatchdogSec=240s" SYSTEMD_DAEMON_WATCHDOG_UPSD="#WatchdogSec=240s" + SYSTEMD_DAEMON_WATCHDOG_UPSLOG="#WatchdogSec=240s" SYSTEMD_DAEMON_WATCHDOG_UPSMON="#WatchdogSec=240s" ], [ dnl "Usual" daemons that happen to be spawned by systemd SYSTEMD_DAEMON_ARGS_UPSD="-F" SYSTEMD_DAEMON_TYPE_UPSD="simple" + SYSTEMD_DAEMON_ARGS_UPSLOG="-F" + SYSTEMD_DAEMON_TYPE_UPSLOG="simple" SYSTEMD_DAEMON_ARGS_UPSMON="-F" SYSTEMD_DAEMON_TYPE_UPSMON="simple" SYSTEMD_DAEMON_ARGS_DRIVER="" SYSTEMD_DAEMON_TYPE_DRIVER="forking" SYSTEMD_DAEMON_NOTIFYACCESS_DRIVER="" SYSTEMD_DAEMON_NOTIFYACCESS_UPSD="" + SYSTEMD_DAEMON_NOTIFYACCESS_UPSLOG="" SYSTEMD_DAEMON_NOTIFYACCESS_UPSMON="" dnl Watchdog should not be configured for not-notifying units, right? SYSTEMD_DAEMON_WATCHDOG_DRIVER="#WatchdogSec=240s" SYSTEMD_DAEMON_WATCHDOG_UPSD="#WatchdogSec=240s" + SYSTEMD_DAEMON_WATCHDOG_UPSLOG="#WatchdogSec=240s" SYSTEMD_DAEMON_WATCHDOG_UPSMON="#WatchdogSec=240s" ]) @@ -4879,14 +4888,18 @@ AC_SUBST(LIBSYSTEMD_CFLAGS) AC_SUBST(LIBSYSTEMD_LIBS) AC_SUBST(SYSTEMD_DAEMON_ARGS_UPSD) AC_SUBST(SYSTEMD_DAEMON_TYPE_UPSD) +AC_SUBST(SYSTEMD_DAEMON_ARGS_UPSLOG) +AC_SUBST(SYSTEMD_DAEMON_TYPE_UPSLOG) AC_SUBST(SYSTEMD_DAEMON_ARGS_UPSMON) AC_SUBST(SYSTEMD_DAEMON_TYPE_UPSMON) AC_SUBST(SYSTEMD_DAEMON_ARGS_DRIVER) AC_SUBST(SYSTEMD_DAEMON_TYPE_DRIVER) AC_SUBST(SYSTEMD_DAEMON_NOTIFYACCESS_DRIVER) AC_SUBST(SYSTEMD_DAEMON_NOTIFYACCESS_UPSD) +AC_SUBST(SYSTEMD_DAEMON_NOTIFYACCESS_UPSLOG) AC_SUBST(SYSTEMD_DAEMON_NOTIFYACCESS_UPSMON) AC_SUBST(SYSTEMD_DAEMON_WATCHDOG_UPSD) +AC_SUBST(SYSTEMD_DAEMON_WATCHDOG_UPSLOG) AC_SUBST(SYSTEMD_DAEMON_WATCHDOG_UPSMON) AC_SUBST(SYSTEMD_DAEMON_WATCHDOG_DRIVER) AC_SUBST(SYSTEMD_TMPFILES_PROGRAM) @@ -5547,6 +5560,7 @@ AC_CONFIG_FILES([ scripts/systemd/nut.target scripts/systemd/nut-common-tmpfiles.conf scripts/systemd/nut-driver@.service + scripts/systemd/nut-logger.service scripts/systemd/nut-monitor.service scripts/systemd/nut-server.service scripts/systemd/nut-driver-enumerator.service @@ -5556,6 +5570,7 @@ AC_CONFIG_FILES([ scripts/systemd/nut-driver-enumerator-daemon-activator.path scripts/Solaris/nut-driver-enumerator.xml scripts/Solaris/nut-driver.xml + scripts/Solaris/nut-logger.xml scripts/Solaris/nut-monitor.xml scripts/Solaris/nut-server.xml scripts/Solaris/nut.xml @@ -5592,6 +5607,7 @@ m4_foreach_w([SCRIPTFILE], [ scripts/upsdrvsvcctl/upsdrvsvcctl scripts/systemd/nutshutdown scripts/Solaris/svc-nut-server + scripts/Solaris/svc-nut-logger scripts/Solaris/svc-nut-monitor scripts/Solaris/precheck.py scripts/Solaris/preinstall diff --git a/scripts/Solaris/.gitignore b/scripts/Solaris/.gitignore index 4d4f0e1425..2f18535250 100644 --- a/scripts/Solaris/.gitignore +++ b/scripts/Solaris/.gitignore @@ -7,9 +7,11 @@ /precheck.py /preproto.pl /svc-nut-server +/svc-nut-logger /svc-nut-monitor /nut-driver.xml /nut-driver-enumerator.xml +/nut-logger.xml /nut-monitor.xml /nut-server.xml /nut.xml diff --git a/scripts/Solaris/Makefile.am b/scripts/Solaris/Makefile.am index 3fad462879..59bbee61e4 100644 --- a/scripts/Solaris/Makefile.am +++ b/scripts/Solaris/Makefile.am @@ -8,12 +8,14 @@ PYTHON = @PYTHON@ SOLARIS_SMF_MANIFESTS = \ nut.xml \ nut-server.xml \ + nut-logger.xml \ nut-monitor.xml \ nut-driver.xml \ nut-driver-enumerator.xml SOLARIS_SMF_METHODSCRIPTS = \ svc-nut-server \ + svc-nut-logger \ svc-nut-monitor if WITH_SOLARIS_SMF diff --git a/scripts/Solaris/nut-logger.xml.in b/scripts/Solaris/nut-logger.xml.in new file mode 100644 index 0000000000..88ab145c49 --- /dev/null +++ b/scripts/Solaris/nut-logger.xml.in @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripts/Solaris/svc-nut-logger.in b/scripts/Solaris/svc-nut-logger.in new file mode 100755 index 0000000000..6623dda74a --- /dev/null +++ b/scripts/Solaris/svc-nut-logger.in @@ -0,0 +1,75 @@ +#!/sbin/sh + +# Trivial (better is yet to come) SMF method script to start nut services +# Adapted for OpenIndiana userland from init.d script template in NUT sources +# Adaptation copyright (C) 2016-2025 Jim Klimov + +if [ -z "$SMF_FMRI" ]; then + echo "$0 must be called in SMF context!" >&2 + exit 1 +fi + +# smf(5) +. /lib/svc/share/smf_include.sh || exit + +prefix="@prefix@" +NUT_DIR="@prefix@" +NUT_SBIN_DIR="${NUT_DIR}/sbin" +NUT_LIB_DIR="${NUT_DIR}/lib" +NUT_RUN_DIR="@ALTPIDPATH@" +CONFIG="@CONFPATH@/nut.conf" +DAEMON_CONFIG="@CONFPATH@/upslog.conf" +NUTUSER="@RUN_AS_USER@" +NUTGROUP="@RUN_AS_GROUP@" + +# We anticipate some tighter integration with SMF later: +#NUT_QUIET_INIT_UPSNOTIFY=true +#export NUT_QUIET_INIT_UPSNOTIFY + +if [ -f "$CONFIG" ] ; then + . "$CONFIG" +fi + +if [ -s "$DAEMON_CONFIG" ] ; then + . "$DAEMON_CONFIG" +else + echo "Daemon config file '$DAEMON_CONFIG' not found or populated, not starting anything" >&2 + exit $SMF_EXIT_ERR_CONFIG +fi + +ups_start () { + if [ "$MODE" = "none" ];then + echo "No NUT mode set, not starting anything" >&2 + exit $SMF_EXIT_ERR_CONFIG + fi + + if [ x"${UPSLOG_ARGS-}" = x ; then + echo "UPSLOG_ARGS not found or populated in configuration, not starting anything" >&2 + exit $SMF_EXIT_ERR_CONFIG + fi + + # Default rights inspired by NUT scripts/Solaris/postinstall.in + mkdir -p "@PIDPATH@" # (for privileged processes) + mkdir -p "$NUT_RUN_DIR" && \ + chown "root:$NUTGROUP" "$NUT_RUN_DIR" && \ + chmod 770 "$NUT_RUN_DIR" \ + || exit $SMF_EXIT_ERR_FATAL + + # Fork and background regardless of logging to a file or stdout (-) + LD_LIBRARY_PATH="${NUT_LIB_DIR}:$LD_LIBRARY_PATH" "${NUT_SBIN_DIR}"/upslog -B $UPSLOG_ARGS #> /dev/null 2>&1 +} + +case "$1" in +'start') + ups_start + ;; + +*) + echo "" + echo "Usage: '$0' {start}" + echo "" + exit $SMF_EXIT_ERR_CONFIG + ;; +esac + +exit $? diff --git a/scripts/systemd/.gitignore b/scripts/systemd/.gitignore index e56937b1e7..6d3c186e16 100644 --- a/scripts/systemd/.gitignore +++ b/scripts/systemd/.gitignore @@ -4,6 +4,7 @@ /nut.target /nut-driver.service /nut-driver@.service +/nut-logger.service /nut-monitor.service /nut-server.service /nutshutdown diff --git a/scripts/systemd/Makefile.am b/scripts/systemd/Makefile.am index 577456cb29..c037f11af5 100644 --- a/scripts/systemd/Makefile.am +++ b/scripts/systemd/Makefile.am @@ -11,6 +11,7 @@ systemdsystemunit_DATA = \ nut-driver-enumerator-daemon-activator.service \ nut-driver-enumerator-daemon.service \ nut-driver@.service \ + nut-logger.service \ nut-monitor.service \ nut-server.service \ nut-driver.target \ @@ -34,7 +35,7 @@ sbin_SCRIPTS = ../upsdrvsvcctl/upsdrvsvcctl else !HAVE_SYSTEMD EXTRA_DIST += \ - nut-driver@.service.in nut-monitor.service.in nut-sleep.service \ + nut-driver@.service.in nut-logger.service.in nut-monitor.service.in nut-sleep.service \ nut-server.service.in nutshutdown.in nut-driver.target nut.target.in \ nut-driver-enumerator.path.in nut-driver-enumerator.service.in \ nut-driver-enumerator-daemon-activator.path.in \ diff --git a/scripts/systemd/nut-logger.service.in b/scripts/systemd/nut-logger.service.in new file mode 100644 index 0000000000..914566fc0d --- /dev/null +++ b/scripts/systemd/nut-logger.service.in @@ -0,0 +1,59 @@ +# Network UPS Tools (NUT) systemd integration +# Copyright (C) 2011-2025 by NUT contirbutors +# Distributed under the terms of GPLv2+ +# See https://networkupstools.org/ +# and https://github.com/networkupstools/nut/ + +[Unit] +Description=Network UPS Tools - optional logging daemon (for status collection and analysis) +# Log UPS values to a file for later collection and analysis +After=local-fs.target network.target nut-server.service +# Note: We do not specify Requires nut-server.service because +# the `upsd` daemon(s) may be running on a different machine +# (connected to the UPSes) than this client program. +# The "Wants" directive would try to start the nut-server but +# would not abort if that attempt fails for whatever reason. +Wants=nut-server.service +# Extending the unit does not require *this* file to be edited, you +# can instead drop in an additional piece of configuration, e.g. to +# require the logging client to only start after external networking +# is configured (usable IP addresses appear in the system) you can +# add a `/etc/systemd/system/nut-logger.service.d/network.conf` with: +# [Unit] +# Requires=network-online.target +# After=network-online.target +PartOf=nut.target +Before=nut.target ### not enabled by default, but ordered if enabled by user + +Documentation=man:upslog(8) +Documentation=@NUT_WEBSITE_BASE@/docs/man/upslog.html +Documentation=man:nut.conf(5) +Documentation=@NUT_WEBSITE_BASE@/docs/man/nut.conf.html + +# Should contain UPSLOG_ARGS=... (or a systemd drop-in could provide it) +# with a series of `-m upsname@server,logfile` definitions, where `logfile` +# may be `-` for stdout. See about more variants in man page. +ConditionPathExists=@CONFPATH@/upslog.conf + +[Service] +EnvironmentFile=-@CONFPATH@/nut.conf +EnvironmentFile=@CONFPATH@/upslog.conf +SyslogIdentifier=%N +ExecStartPre=-@SYSTEMD_TMPFILES_PROGRAM@ --create @systemdtmpfilesdir@/nut-common-tmpfiles.conf +ExecStartPre=/bin/test -n "${UPSLOG_ARGS-}" +ExecStart=@SBINDIR@/upslog @SYSTEMD_DAEMON_ARGS_UPSLOG@ $UPSLOG_ARGS +# NOTE: SIGHUP is supported to re-open the log file, +# which is the default systemd ReloadSignal +PIDFile=@PIDPATH@/upslog.pid +# With this program, the PID file always exists and "kill -TERM" in particular +# can be used from command-line or some legacy scripts, it causes a clean and +# intentional exit of the daemon (some other signals are also supported). +# Then systemd should not revive it - hence restart it only on failure: +Restart=on-failure +Type=@SYSTEMD_DAEMON_TYPE_UPSLOG@ +@SYSTEMD_DAEMON_WATCHDOG_UPSLOG@ +@SYSTEMD_DAEMON_NOTIFYACCESS_UPSLOG@ + +[Install] +# WantedBy=nut.target ### not enabled by default +Alias=upslog.service diff --git a/scripts/systemd/nut.target.in b/scripts/systemd/nut.target.in index ed803e2ec0..235848f6b1 100644 --- a/scripts/systemd/nut.target.in +++ b/scripts/systemd/nut.target.in @@ -6,9 +6,10 @@ [Unit] Description=Network UPS Tools - target for power device drivers, data server and monitoring client (if enabled) on this system -After=local-fs.target nut-driver.target nut-server.service nut-monitor.service +After=local-fs.target nut-driver.target nut-server.service nut-monitor.service nut-logger.service Wants=local-fs.target nut-driver.target nut-server.service nut-monitor.service # network.target +# nut-logger.service ### not enabled by default # TODO: Dedicated man pages? Documentation=man:ups.conf(5) From 950dc6bec21164214798ec0c90c620fc2ef71b35 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 2 Jan 2025 19:59:52 +0100 Subject: [PATCH 02/11] docs/man/upslog.txt: clarify that "-m tuple" option(s) can override "-s ups -l file" in effect Signed-off-by: Jim Klimov --- docs/man/upslog.txt | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/docs/man/upslog.txt b/docs/man/upslog.txt index 1f0b64efc0..478af0f9ac 100644 --- a/docs/man/upslog.txt +++ b/docs/man/upslog.txt @@ -22,6 +22,13 @@ variables that interest you, format them, and write them to a file. The default format string includes variables that are supported by many common UPS models. See the description below to make your own. +NOTE: Historically this daemon supported logging of data for one UPS system +(specified by the `-s` option) into one log file name or `stdout` (specified +by the `-l` option). Later it allowed to log several devices (each into its +destination) as specified by multiple `-m tuple` options. The two modes are +effectively exclusive of each other (single-UPS options are ignored if tuples +are also provided). + OPTIONS ------- @@ -70,6 +77,8 @@ Store the results in this file. + You can use "-" for stdout, but upslog will remain in the foreground by default. ++ +Ignored if you also provide `-m tuple` option(s). *-F*:: upslog will run in the foreground, regardless of logging target. @@ -80,11 +89,25 @@ upslog will run in the background, regardless of logging target. *-s* 'ups':: Monitor this UPS. The format for this option is +upsname[@hostname[:port]]+. The default hostname is "localhost". ++ +Ignored if you also provide `-m tuple` option(s). *-m* 'tuple':: -Monitor multiple UPSs. The format for this option is a tuple of -ups and logfile separated by commas. An example would be: -`upsname@hostname:9999,/var/log/nut/cps.log` +Monitor multiple UPSs (provided several instances of such option). ++ +Overrides the single-UPS settings passed by `-s` and `-l` options. ++ +The format for this option is a tuple of UPS system and log file +specification, separated by commas. An example would be: +---- +upsname@hostname:9999,/var/log/nut/cps.log +---- ++ +Tuples may specify `-` as the logfile, to emit messages on `stdout` +(e.g. to be collected by the system journal for services). ++ +Use of `stdout` via tuple-based logging specifications does not +imply that upslog will remain in the foreground by default. *-u* 'username':: From 0029bc24ff6507e287eefdfe84777b3754d3101d Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 2 Jan 2025 20:05:27 +0100 Subject: [PATCH 03/11] clients/upslog.c: help(): clarify that "-m tuple" option(s) can override "-s ups -l file" in effect Signed-off-by: Jim Klimov --- clients/upslog.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/clients/upslog.c b/clients/upslog.c index 33b8505822..4b88cd9421 100644 --- a/clients/upslog.c +++ b/clients/upslog.c @@ -157,10 +157,15 @@ static void help(const char *prog) printf(" -F - stay foregrounded even if logging into a file\n"); printf(" -B - stay backgrounded even if logging to stdout\n"); printf(" -p - Base name for PID file (defaults to \"%s\")\n", prog); + printf(" - NOTE: PID file is written regardless of fore/back-grounding\n"); printf(" -s - Monitor UPS - @[:]\n"); printf(" - Example: -s myups@server\n"); printf(" -m - Monitor UPS \n"); printf(" - Example: -m myups@server,/var/log/myups.log\n"); + printf(" - NOTE: You can use '-' as logfile for stdout\n"); + printf(" and it would not imply foregrounding\n"); + printf(" - NOTE: '-s ups' and/or '-l file' options are ignored\n"); + printf(" if tuples are used, but you can specify many tuples\n"); printf(" -u - Switch to if started as root\n"); printf(" -V - Display the version of this software\n"); printf(" -h - Display this help text\n"); From 4cd729e618d4b7883755742f449ccff219817d30 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 2 Jan 2025 20:46:02 +0100 Subject: [PATCH 04/11] configure.ac: refactor detection of systemd directories (yes/auto mode via pkg-config) Signed-off-by: Jim Klimov --- configure.ac | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/configure.ac b/configure.ac index 73318fbd7f..5f8e5aeb8a 100644 --- a/configure.ac +++ b/configure.ac @@ -3960,11 +3960,17 @@ AC_ARG_WITH([systemdsystemunitdir], case "${systemdsystemunitdir}" in yes|auto|"") AS_IF([test x"$have_PKG_CONFIG" = xyes], - [systemdsystemunitdir="`$PKG_CONFIG --variable=systemdsystemunitdir systemd 2>/dev/null`" && test -n "$systemdsystemunitdir" || systemdsystemunitdir="`$PKG_CONFIG --variable=systemdsystemunitdir libsystemd 2>/dev/null`"], - [AS_IF([test "${systemdsystemunitdir}" = yes], + [def_systemdsystemunitdir="`$PKG_CONFIG --variable=systemdsystemunitdir systemd 2>/dev/null`" && test -n "$def_systemdsystemunitdir" || \ + def_systemdsystemunitdir="`$PKG_CONFIG --variable=systemdsystemunitdir libsystemd 2>/dev/null`" || def_systemdsystemunitdir=""], + [def_systemdsystemunitdir=""]) + + AS_IF([test x"${def_systemdsystemunitdir}" = x], [ + AS_IF([test "${systemdsystemunitdir}" = yes], [AC_MSG_ERROR([--with-systemdsystemunitdir=${systemdsystemunitdir} was requested, but PKG_CONFIG could not be queried for the system settings])]) - systemdsystemunitdir="" - ]) + systemdsystemunitdir="" + ], [systemdsystemunitdir="${def_systemdsystemunitdir}"]) + + unset def_systemdsystemunitdir ;; no) systemdsystemunitdir="" @@ -4002,11 +4008,17 @@ if test -n "${systemdsystemunitdir}"; then case "${systemdshutdowndir}" in yes|auto|"") AS_IF([test x"$have_PKG_CONFIG" = xyes], - [systemdshutdowndir="`$PKG_CONFIG --variable=systemdshutdowndir systemd 2>/dev/null`" && test -n "$systemdshutdowndir" || systemdshutdowndir="`$PKG_CONFIG --variable=systemdshutdowndir libsystemd 2>/dev/null`"], - [AS_IF([test "${systemdshutdowndir}" = yes], + [def_systemdshutdowndir="`$PKG_CONFIG --variable=systemdshutdowndir systemd 2>/dev/null`" && test -n "$def_systemdshutdowndir" || \ + def_systemdshutdowndir="`$PKG_CONFIG --variable=systemdshutdowndir libsystemd 2>/dev/null`" || def_systemdshutdowndir=""], + [def_systemdshutdowndir=""]) + + AS_IF([test x"${def_systemdshutdowndir}" = x], [ + AS_IF([test "${systemdshutdowndir}" = yes], [AC_MSG_ERROR([--with-systemdshutdowndir=${systemdshutdowndir} was requested, but PKG_CONFIG could not be queried for the system settings])]) - systemdshutdowndir="" - ]) + systemdshutdowndir="" + ], [systemdshutdowndir="${def_systemdshutdowndir}"]) + + unset def_systemdshutdowndir ;; no) systemdshutdowndir="" @@ -4035,11 +4047,17 @@ AC_ARG_WITH([systemdtmpfilesdir], case "${systemdtmpfilesdir}" in yes|auto|"") AS_IF([test x"$have_PKG_CONFIG" = xyes], - [systemdtmpfilesdir="`$PKG_CONFIG --variable=tmpfilesdir systemd 2>/dev/null`" && test -n "$systemdtmpfilesdir" || systemdtmpfilesdir="`$PKG_CONFIG --variable=tmpfilesdir libsystemd 2>/dev/null`"], - [AS_IF([test "${systemdtmpfilesdir}" = yes], + [def_systemdtmpfilesdir="`$PKG_CONFIG --variable=tmpfilesdir systemd 2>/dev/null`" && test -n "$def_systemdtmpfilesdir" || \ + def_systemdtmpfilesdir="`$PKG_CONFIG --variable=tmpfilesdir libsystemd 2>/dev/null`" || def_systemdtmpfilesdir=""], + [def_systemdtmpfilesdir=""]) + + AS_IF([test x"${def_systemdtmpfilesdir}" = x], [ + AS_IF([test "${systemdtmpfilesdir}" = yes], [AC_MSG_ERROR([--with-systemdtmpfilesdir=${systemdtmpfilesdir} was requested, but PKG_CONFIG could not be queried for the system settings])]) - systemdtmpfilesdir="" - ]) + systemdtmpfilesdir="" + ], [systemdtmpfilesdir="${def_systemdtmpfilesdir}"]) + + unset def_systemdtmpfilesdir ;; no) systemdtmpfilesdir="" From bda20863147264f9bf17fc041681b042a6ac1ac1 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 2 Jan 2025 21:06:20 +0100 Subject: [PATCH 05/11] configure.ac, docs/configure.txt, NEWS.adoc, docs/nut.dict: introduce --with-systemdsystempresetdir setting Signed-off-by: Jim Klimov --- NEWS.adoc | 2 ++ configure.ac | 43 +++++++++++++++++++++++++++++++++++++++++++ docs/configure.txt | 15 +++++++++++++++ docs/nut.dict | 3 ++- 4 files changed, 62 insertions(+), 1 deletion(-) diff --git a/NEWS.adoc b/NEWS.adoc index c4ad725faf..058ca5fc4f 100644 --- a/NEWS.adoc +++ b/NEWS.adoc @@ -329,6 +329,8 @@ https://github.com/networkupstools/nut/milestone/11 should be handled similar (avoid stale UPS data and rash decisions) for summer/winter time change on non-UTC deployments, a debugger suspending the `upsmon` process, etc. [#2597] + * Introduced delivery of default systemd presets (lists of enabled/disabled + units). [#2721] - gamatronic driver revised for safer memory operations; this was reported to have fixed a Segmentation Fault seen in earlier NUT releases with diff --git a/configure.ac b/configure.ac index 5f8e5aeb8a..5442195dab 100644 --- a/configure.ac +++ b/configure.ac @@ -3998,6 +3998,48 @@ dnl This option is only provided so that make distcheck can override it, dnl otherwise we ask pkg-config whenever --with-systemdsystemunitdir is dnl given +dnl Similarly for presets (list of svcs enabled/disabled by default) +AC_MSG_CHECKING(whether to install systemd preset files) +AC_ARG_WITH([systemdsystempresetdir], + [AS_HELP_STRING([--with-systemdsystempresetdir=DIR], [Directory for systemd preset files (auto)])], + [systemdsystempresetdir="${withval}"], + [systemdsystempresetdir="auto"]) + +dnl Note: this option is enabled only if systemdsystemunitdir is not trivial +if test -n "${systemdsystemunitdir}"; then + case "${systemdsystempresetdir}" in + yes|auto|"") + AS_IF([test x"$have_PKG_CONFIG" = xyes], + [def_systemdsystempresetdir="`$PKG_CONFIG --variable=systemdsystempresetdir systemd 2>/dev/null`" && test -n "$def_systemdsystempresetdir" || \ + def_systemdsystempresetdir="`$PKG_CONFIG --variable=systemdsystempresetdir libsystemd 2>/dev/null`" || def_systemdsystempresetdir=""], + [def_systemdsystempresetdir=""]) + + AS_IF([test x"${def_systemdsystempresetdir}" = x], [ + AS_IF([test "${systemdsystempresetdir}" = yes], + [AC_MSG_ERROR([--with-systemdsystempresetdir=${systemdsystempresetdir} was requested, but PKG_CONFIG could not be queried for the system settings])]) + systemdsystempresetdir="" + ], [systemdsystempresetdir="${def_systemdsystempresetdir}"]) + + unset def_systemdsystempresetdir + ;; + no) + systemdsystempresetdir="" + ;; + *) + AS_IF([test -d "${systemdsystempresetdir}"], [], + [AC_MSG_WARN([--with-systemdsystempresetdir='${systemdsystempresetdir}' was requested, but that location does not currently exist in build environment - just so you know...])]) + ;; + esac +fi +if test "${systemdsystempresetdir}" = "auto" ; then systemdsystempresetdir=""; fi +if test -n "${systemdsystempresetdir}"; then + AC_MSG_RESULT(using ${systemdsystempresetdir}) + NUT_REPORT_PATH_INTEGRATIONS([Service unit presets for systemd], [${systemdsystempresetdir}]) +else + AC_MSG_RESULT(no) +fi + +dnl Similarly for shutdown integration hooks AC_MSG_CHECKING(whether to install systemd shutdown files) AC_ARG_WITH([systemdshutdowndir], AS_HELP_STRING([--with-systemdshutdowndir=DIR], [Directory for systemd shutdown scripts (auto)]), @@ -4957,6 +4999,7 @@ AC_SUBST(htmldocdir) AC_SUBST(htmlmandir) AC_SUBST(pkgconfigdir) AC_SUBST(systemdsystemunitdir) +AC_SUBST(systemdsystempresetdir) AC_SUBST(systemdshutdowndir) AC_SUBST(systemdtmpfilesdir) AC_SUBST(auglensdir) diff --git a/docs/configure.txt b/docs/configure.txt index cc9899e69b..305f29370d 100644 --- a/docs/configure.txt +++ b/docs/configure.txt @@ -738,6 +738,21 @@ settings with pkg-config, or fail configuration if not possible. Use `--with-systemdsystemunitdir=no` to disable this feature altogether. + --with-systemdsystempresetdir=PATH + +Where to install Linux systemd unit presets (lists of services enabled +or disabled by default). Useless and harmless on other OSes, including +Linux distributions without systemd, just adding a little noise to the +configure script output. + +Use `--with-systemdsystempresetdir=auto` (default) to detect the settings +using pkg-config if possible. + +Use `--with-systemdsystempresetdir(=yes)` to require detection of these +settings with pkg-config, or fail configuration if not possible. + +Use `--with-systemdsystempresetdir=no` to disable this feature altogether. + --with-systemdshutdowndir=PATH Where to install Linux systemd unit definitions for shutdown handling. diff --git a/docs/nut.dict b/docs/nut.dict index 1cc4c8f6cf..cdb1b84634 100644 --- a/docs/nut.dict +++ b/docs/nut.dict @@ -1,4 +1,4 @@ -personal_ws-1.1 en 3270 utf-8 +personal_ws-1.1 en 3272 utf-8 AAC AAS ABI @@ -2963,6 +2963,7 @@ syslogd systemctl systemd systemdshutdowndir +systemdsystempresetdir systemdsystemunitdir systemdtmpfilesdir systemtest From f677fe3bc93ed0e5b58911ee42baa5dfd822ce7d Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 2 Jan 2025 21:24:12 +0100 Subject: [PATCH 06/11] scripts/systemd/nut-sleep.service: typo fix, bump (C) Signed-off-by: Jim Klimov --- scripts/systemd/nut-sleep.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/systemd/nut-sleep.service b/scripts/systemd/nut-sleep.service index bb93c8c832..e870735038 100644 --- a/scripts/systemd/nut-sleep.service +++ b/scripts/systemd/nut-sleep.service @@ -5,7 +5,7 @@ # and https://github.com/networkupstools/nut/ # A rather blunt solution for system sleeping support, for cases where -# we can not use a native libssytemd "inhibitor interface". This helps +# we can not use a native libsystemd "inhibitor interface". This helps # avoid NUT shutting down a woken-up system just because its power state # was critical before the sleep, and a next-read timestamp was not seen # (deemed to be a stale UPS, meaning lost comms during critical state, From 1df7145c7de22e2ce56028cad72f67718960a385 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 2 Jan 2025 21:38:48 +0100 Subject: [PATCH 07/11] scripts/systemd/nut-systemd.preset, UPGRADING.adoc: introduce the file, document the units and why they are enabled or disabled by default [#2721] Signed-off-by: Jim Klimov --- UPGRADING.adoc | 5 +++ scripts/systemd/Makefile.am | 8 +++- scripts/systemd/nut-systemd.preset | 65 ++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 scripts/systemd/nut-systemd.preset diff --git a/UPGRADING.adoc b/UPGRADING.adoc index b3d5924cd9..01037dd38f 100644 --- a/UPGRADING.adoc +++ b/UPGRADING.adoc @@ -44,6 +44,11 @@ Changes from 2.8.2 to 2.8.3 Please use it, it immensely helps with community troubleshooting! [issue #1949] +- When packaging or custom-building for (Linux) distributions with systemd, + you can now take advantage of `nut-systemd.preset` file to enable or + disable certain NUT units by default; its comments document each choice. + [issue #2721] + - `upsmon` should now integrate natively with systemd-driven OS sleep events (built with systemd version 221 or newer "inhibitor interface"), so various hacks previously packaged into `/usr/lib/systemd/system-sleep/` scripts or diff --git a/scripts/systemd/Makefile.am b/scripts/systemd/Makefile.am index c037f11af5..fdef7cb6dc 100644 --- a/scripts/systemd/Makefile.am +++ b/scripts/systemd/Makefile.am @@ -25,7 +25,11 @@ endif !WITH_LIBSYSTEMD_INHIBITOR systemdtmpfiles_DATA = \ nut-common-tmpfiles.conf -EXTRA_DIST += nut-driver.target nut-sleep.service +systemdsystempreset_DATA = \ + nut-systemd.preset + +# Add files not generated from .in templates +EXTRA_DIST += nut-driver.target nut-sleep.service nut-systemd.preset systemdshutdown_SCRIPTS = nutshutdown @@ -36,7 +40,7 @@ sbin_SCRIPTS = ../upsdrvsvcctl/upsdrvsvcctl else !HAVE_SYSTEMD EXTRA_DIST += \ nut-driver@.service.in nut-logger.service.in nut-monitor.service.in nut-sleep.service \ - nut-server.service.in nutshutdown.in nut-driver.target nut.target.in \ + nut-server.service.in nutshutdown.in nut-driver.target nut.target.in nut-systemd.preset \ nut-driver-enumerator.path.in nut-driver-enumerator.service.in \ nut-driver-enumerator-daemon-activator.path.in \ nut-driver-enumerator-daemon-activator.service.in \ diff --git a/scripts/systemd/nut-systemd.preset b/scripts/systemd/nut-systemd.preset new file mode 100644 index 0000000000..afe682920c --- /dev/null +++ b/scripts/systemd/nut-systemd.preset @@ -0,0 +1,65 @@ +# Network UPS Tools (NUT) systemd integration +# Copyright (C) 2011-2025 by NUT contirbutors +# Distributed under the terms of GPLv2+ +# See https://networkupstools.org/ +# and https://github.com/networkupstools/nut/ + +# This file enables a default selection of NUT systemd units, +# reasonable for a typical server with one or a few UPS devices +# (their drivers, NDE, and data server), and the upsmon client. +# Adapt to your system as needed. + +# There are several separate variants of NDE usage to process the +# "ups.conf" file and create/update/remove `nut-driver@.service` +# unit instances: +# * Manual run of `nut-driver-enumerator.sh (--reconfigure)` +# * Single run at system start-up (nut-driver-enumerator.service unit) +# ** perhaps additionally upon edits of the file (path unit), +# if it works (may get ignored on busy systems) +# * Daemon mode that runs once to update the nut-driver population, +# and then loops to to pick up any subsequent changes (maybe more +# reliably than the filesystem notification processing would allow). +# ** nut-driver-enumerator-daemon.service provides the daemon +# ** nut-driver-enumerator-daemon-activator.* units optionally +# reload it if "ups.conf" is edited (if the path unit does work) +# and apply changes without waiting for the inter-loop sleep. +# Typical systems do not monitor hordes of devices with a dynamically +# changing population of those (e.g. data center monitoring appliances), +# so the daemon mode is an overkill for these smaller use-cases. +disable nut-driver-enumerator-daemon-activator.path +disable nut-driver-enumerator-daemon-activator.service +disable nut-driver-enumerator-daemon.service +enable nut-driver-enumerator.path +enable nut-driver-enumerator.service + +# Activate systemd unit instances prepared by NDE (service above +# or a manual run of the script), each wrapping one NUT driver. +# Requires "ups.conf" with corresponding section for the device: +enable nut-driver.target +# I don't think a template can be activated/deactivated; anyhow +# this is NDE's bread and butter at run-time: +#enable nut-driver@.service + +# Activate the "upsd" data server, to represent drivers on the network. +# Requires "ups.conf", "upsd.conf", "upsd.users": +enable nut-server.service + +# Activate the "upsmon" client to shut down the local system. +# Can run on same or different system as the data server. +# Requires "upsmon.conf": +enable nut-monitor.service + +# Pull in activated units, to orchestrate their starting or stopping +# in one command: +enable nut.target + +# OPTIONAL: Normally NUT programs are built to use the native libsystemd +# "inhibitor interface" to gracefully handle clock jumps when the server +# sleeps and later wakes up. If this is not possible for whatever reason, +# this "sleep hook" unit provides a workaround (stop/start nut.target): +disable nut-sleep.service + +# OPTIONAL: Log snapshots of UPS state into a file (or stdout to +# systemd journal); needs an "upslog.conf" file defining tuples like +# UPSLOG_ARGS="-m ups,file -m ups,file..." +disable nut-logger.service From abcd241b2ce8f3f60e4566f9438cb6479757045f Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 2 Jan 2025 21:45:29 +0100 Subject: [PATCH 08/11] scripts/systemd/nut*.in: bump (C) to 2025 Signed-off-by: Jim Klimov --- scripts/systemd/nut-driver-enumerator-daemon-activator.path.in | 2 +- .../systemd/nut-driver-enumerator-daemon-activator.service.in | 2 +- scripts/systemd/nut-driver-enumerator-daemon.service.in | 2 +- scripts/systemd/nut-driver-enumerator.path.in | 2 +- scripts/systemd/nut-driver-enumerator.service.in | 2 +- scripts/systemd/nut-driver.target | 2 +- scripts/systemd/nut-driver@.service.in | 2 +- scripts/systemd/nut-monitor.service.in | 2 +- scripts/systemd/nut-server.service.in | 2 +- scripts/systemd/nut-sleep.service | 2 +- scripts/systemd/nut.target.in | 2 +- scripts/systemd/nutshutdown.in | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/scripts/systemd/nut-driver-enumerator-daemon-activator.path.in b/scripts/systemd/nut-driver-enumerator-daemon-activator.path.in index 7917d343e5..d8a78d520b 100644 --- a/scripts/systemd/nut-driver-enumerator-daemon-activator.path.in +++ b/scripts/systemd/nut-driver-enumerator-daemon-activator.path.in @@ -1,5 +1,5 @@ # Network UPS Tools (NUT) systemd integration -# Copyright (C) 2011-2024 by NUT contirbutors +# Copyright (C) 2011-2025 by NUT contirbutors # Distributed under the terms of GPLv2+ # See https://networkupstools.org/ # and https://github.com/networkupstools/nut/ diff --git a/scripts/systemd/nut-driver-enumerator-daemon-activator.service.in b/scripts/systemd/nut-driver-enumerator-daemon-activator.service.in index 33c190cf57..f71bc64135 100644 --- a/scripts/systemd/nut-driver-enumerator-daemon-activator.service.in +++ b/scripts/systemd/nut-driver-enumerator-daemon-activator.service.in @@ -1,5 +1,5 @@ # Network UPS Tools (NUT) systemd integration -# Copyright (C) 2011-2024 by NUT contirbutors +# Copyright (C) 2011-2025 by NUT contirbutors # Distributed under the terms of GPLv2+ # See https://networkupstools.org/ # and https://github.com/networkupstools/nut/ diff --git a/scripts/systemd/nut-driver-enumerator-daemon.service.in b/scripts/systemd/nut-driver-enumerator-daemon.service.in index 6f5f4e0a78..0f7dd9e9fb 100644 --- a/scripts/systemd/nut-driver-enumerator-daemon.service.in +++ b/scripts/systemd/nut-driver-enumerator-daemon.service.in @@ -1,5 +1,5 @@ # Network UPS Tools (NUT) systemd integration -# Copyright (C) 2011-2024 by NUT contirbutors +# Copyright (C) 2011-2025 by NUT contirbutors # Distributed under the terms of GPLv2+ # See https://networkupstools.org/ # and https://github.com/networkupstools/nut/ diff --git a/scripts/systemd/nut-driver-enumerator.path.in b/scripts/systemd/nut-driver-enumerator.path.in index 826dccebc5..d06830e2ac 100644 --- a/scripts/systemd/nut-driver-enumerator.path.in +++ b/scripts/systemd/nut-driver-enumerator.path.in @@ -1,5 +1,5 @@ # Network UPS Tools (NUT) systemd integration -# Copyright (C) 2011-2024 by NUT contirbutors +# Copyright (C) 2011-2025 by NUT contirbutors # Distributed under the terms of GPLv2+ # See https://networkupstools.org/ # and https://github.com/networkupstools/nut/ diff --git a/scripts/systemd/nut-driver-enumerator.service.in b/scripts/systemd/nut-driver-enumerator.service.in index c28bf18817..3c80d1881d 100644 --- a/scripts/systemd/nut-driver-enumerator.service.in +++ b/scripts/systemd/nut-driver-enumerator.service.in @@ -1,5 +1,5 @@ # Network UPS Tools (NUT) systemd integration -# Copyright (C) 2011-2024 by NUT contirbutors +# Copyright (C) 2011-2025 by NUT contirbutors # Distributed under the terms of GPLv2+ # See https://networkupstools.org/ # and https://github.com/networkupstools/nut/ diff --git a/scripts/systemd/nut-driver.target b/scripts/systemd/nut-driver.target index c22a593d68..a29e0ddb11 100644 --- a/scripts/systemd/nut-driver.target +++ b/scripts/systemd/nut-driver.target @@ -1,5 +1,5 @@ # Network UPS Tools (NUT) systemd integration -# Copyright (C) 2011-2024 by NUT contirbutors +# Copyright (C) 2011-2025 by NUT contirbutors # Distributed under the terms of GPLv2+ # See https://networkupstools.org/ # and https://github.com/networkupstools/nut/ diff --git a/scripts/systemd/nut-driver@.service.in b/scripts/systemd/nut-driver@.service.in index af94ae85bf..b96b250eaf 100644 --- a/scripts/systemd/nut-driver@.service.in +++ b/scripts/systemd/nut-driver@.service.in @@ -1,5 +1,5 @@ # Network UPS Tools (NUT) systemd integration -# Copyright (C) 2011-2024 by NUT contirbutors +# Copyright (C) 2011-2025 by NUT contirbutors # Distributed under the terms of GPLv2+ # See https://networkupstools.org/ # and https://github.com/networkupstools/nut/ diff --git a/scripts/systemd/nut-monitor.service.in b/scripts/systemd/nut-monitor.service.in index e378080698..ebc23b6daa 100644 --- a/scripts/systemd/nut-monitor.service.in +++ b/scripts/systemd/nut-monitor.service.in @@ -1,5 +1,5 @@ # Network UPS Tools (NUT) systemd integration -# Copyright (C) 2011-2024 by NUT contirbutors +# Copyright (C) 2011-2025 by NUT contirbutors # Distributed under the terms of GPLv2+ # See https://networkupstools.org/ # and https://github.com/networkupstools/nut/ diff --git a/scripts/systemd/nut-server.service.in b/scripts/systemd/nut-server.service.in index 8b964b077c..d955fd8a66 100644 --- a/scripts/systemd/nut-server.service.in +++ b/scripts/systemd/nut-server.service.in @@ -1,5 +1,5 @@ # Network UPS Tools (NUT) systemd integration -# Copyright (C) 2011-2024 by NUT contirbutors +# Copyright (C) 2011-2025 by NUT contirbutors # Distributed under the terms of GPLv2+ # See https://networkupstools.org/ # and https://github.com/networkupstools/nut/ diff --git a/scripts/systemd/nut-sleep.service b/scripts/systemd/nut-sleep.service index e870735038..73f30129ff 100644 --- a/scripts/systemd/nut-sleep.service +++ b/scripts/systemd/nut-sleep.service @@ -1,5 +1,5 @@ # Network UPS Tools (NUT) systemd integration -# Copyright (C) 2011-2024 by NUT contirbutors +# Copyright (C) 2011-2025 by NUT contirbutors # Distributed under the terms of GPLv2+ # See https://networkupstools.org/ # and https://github.com/networkupstools/nut/ diff --git a/scripts/systemd/nut.target.in b/scripts/systemd/nut.target.in index 235848f6b1..ed51cde30a 100644 --- a/scripts/systemd/nut.target.in +++ b/scripts/systemd/nut.target.in @@ -1,5 +1,5 @@ # Network UPS Tools (NUT) systemd integration -# Copyright (C) 2011-2024 by NUT contirbutors +# Copyright (C) 2011-2025 by NUT contirbutors # Distributed under the terms of GPLv2+ # See https://networkupstools.org/ # and https://github.com/networkupstools/nut/ diff --git a/scripts/systemd/nutshutdown.in b/scripts/systemd/nutshutdown.in index 0c60ec9e64..4c3a0c8030 100755 --- a/scripts/systemd/nutshutdown.in +++ b/scripts/systemd/nutshutdown.in @@ -8,7 +8,7 @@ # and their configuration files to be present locally and on still-mounted # filesystems (may be read-only). # -# Copyright (C) 2011-2024 by NUT contirbutors +# Copyright (C) 2011-2025 by NUT contirbutors # Michal Hlavinka, Laurent Bigonville, Arnaud Quette, Jim Klimov et al. # # See https://networkupstools.org/ From ed68cc91c55a62da4f1c5d978c025710d308f907 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 2 Jan 2025 21:47:34 +0100 Subject: [PATCH 09/11] scripts/systemd/nut-driver.target et al: make it a .in template [#722] Signed-off-by: Jim Klimov --- configure.ac | 1 + scripts/systemd/.gitignore | 2 ++ scripts/systemd/Makefile.am | 4 ++-- scripts/systemd/{nut-driver.target => nut-driver.target.in} | 0 4 files changed, 5 insertions(+), 2 deletions(-) rename scripts/systemd/{nut-driver.target => nut-driver.target.in} (100%) diff --git a/configure.ac b/configure.ac index 5442195dab..a8c8b44aef 100644 --- a/configure.ac +++ b/configure.ac @@ -5620,6 +5620,7 @@ AC_CONFIG_FILES([ scripts/systemd/Makefile scripts/systemd/nut.target scripts/systemd/nut-common-tmpfiles.conf + scripts/systemd/nut-driver.target scripts/systemd/nut-driver@.service scripts/systemd/nut-logger.service scripts/systemd/nut-monitor.service diff --git a/scripts/systemd/.gitignore b/scripts/systemd/.gitignore index 6d3c186e16..93843a6e1f 100644 --- a/scripts/systemd/.gitignore +++ b/scripts/systemd/.gitignore @@ -2,7 +2,9 @@ /nut-common-tmpfiles.conf.in /nut-common-tmpfiles.conf /nut.target +# Singular nut-driver.service is obsolete, help with old build workspaces: /nut-driver.service +/nut-driver.target /nut-driver@.service /nut-logger.service /nut-monitor.service diff --git a/scripts/systemd/Makefile.am b/scripts/systemd/Makefile.am index fdef7cb6dc..cd61614704 100644 --- a/scripts/systemd/Makefile.am +++ b/scripts/systemd/Makefile.am @@ -29,7 +29,7 @@ systemdsystempreset_DATA = \ nut-systemd.preset # Add files not generated from .in templates -EXTRA_DIST += nut-driver.target nut-sleep.service nut-systemd.preset +EXTRA_DIST += nut-sleep.service nut-systemd.preset systemdshutdown_SCRIPTS = nutshutdown @@ -40,7 +40,7 @@ sbin_SCRIPTS = ../upsdrvsvcctl/upsdrvsvcctl else !HAVE_SYSTEMD EXTRA_DIST += \ nut-driver@.service.in nut-logger.service.in nut-monitor.service.in nut-sleep.service \ - nut-server.service.in nutshutdown.in nut-driver.target nut.target.in nut-systemd.preset \ + nut-server.service.in nutshutdown.in nut-driver.target.in nut.target.in nut-systemd.preset \ nut-driver-enumerator.path.in nut-driver-enumerator.service.in \ nut-driver-enumerator-daemon-activator.path.in \ nut-driver-enumerator-daemon-activator.service.in \ diff --git a/scripts/systemd/nut-driver.target b/scripts/systemd/nut-driver.target.in similarity index 100% rename from scripts/systemd/nut-driver.target rename to scripts/systemd/nut-driver.target.in From 0e8a1583a462879ce06d60277528437ff9003cbc Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 2 Jan 2025 21:52:25 +0100 Subject: [PATCH 10/11] scripts/systemd/Makefile.am: wrap long lines in EXTRA_DIST Signed-off-by: Jim Klimov --- scripts/systemd/Makefile.am | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/systemd/Makefile.am b/scripts/systemd/Makefile.am index cd61614704..58ecac0f68 100644 --- a/scripts/systemd/Makefile.am +++ b/scripts/systemd/Makefile.am @@ -39,8 +39,11 @@ sbin_SCRIPTS = ../upsdrvsvcctl/upsdrvsvcctl else !HAVE_SYSTEMD EXTRA_DIST += \ - nut-driver@.service.in nut-logger.service.in nut-monitor.service.in nut-sleep.service \ - nut-server.service.in nutshutdown.in nut-driver.target.in nut.target.in nut-systemd.preset \ + nut.target.in nut-systemd.preset \ + nut-driver@.service.in nut-driver.target.in \ + nut-server.service.in \ + nut-logger.service.in nut-monitor.service.in \ + nut-sleep.service nutshutdown.in \ nut-driver-enumerator.path.in nut-driver-enumerator.service.in \ nut-driver-enumerator-daemon-activator.path.in \ nut-driver-enumerator-daemon-activator.service.in \ From 91993a9725477ed07bd25413303cbdf71757fc11 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Fri, 3 Jan 2025 01:09:00 +0100 Subject: [PATCH 11/11] Makefile.am: enable distcheck --with-systemdsystempresetdir Signed-off-by: Jim Klimov --- Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile.am b/Makefile.am index c96718c0a8..2d159b4378 100644 --- a/Makefile.am +++ b/Makefile.am @@ -76,6 +76,7 @@ DISTCHECK_VALGRIND_FLAGS = --with-all=auto --with-ssl=auto --with-doc=skip --wit # Note: this rule uses envvar DISTCHECK_FLAGS expanded at run-time DISTCHECK_CONFIGURE_FLAGS = ${DISTCHECK_FLAGS} \ --with-systemdsystemunitdir='$${prefix}/lib/systemd/system' \ + --with-systemdsystempresetdir='$${prefix}/usr/lib/systemd/system-preset' \ --with-systemdshutdowndir='$${prefix}/lib/systemd/system-shutdown' \ --with-systemdtmpfilesdir='$${prefix}/usr/lib/tmpfiles.d' \ --with-augeas-lenses-dir='$${prefix}/usr/share/augeas/lenses' \