Skip to content
Merged
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
1 change: 1 addition & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ DISTCHECK_VALGRIND_FLAGS = --with-all=auto --with-ssl=auto --with-doc=skip --wit
DISTCHECK_CONFIGURE_FLAGS = ${DISTCHECK_FLAGS} \
--with-systemdsystemunitdir='$${prefix}/lib/systemd/system' \
--with-systemdshutdowndir='$${prefix}/lib/systemd/system-shutdown' \
--with-systemdtmpfilesdir='$${prefix}/usr/lib/tmpfiles.d' \
--with-augeas-lenses-dir='$${prefix}/usr/share/augeas/lenses' \
--with-hotplug-dir='$${prefix}/etc/hotplug' \
--with-udev-dir='$${prefix}/etc/udev' \
Expand Down
4 changes: 4 additions & 0 deletions autogen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ then
fi
fi

if [ ! -e scripts/systemd/nut-common.tmpfiles.in ]; then
echo '# autoconf requires this file exists before generating configure script' > scripts/systemd/nut-common.tmpfiles.in
fi

# now we can safely call autoreconf
echo "Calling autoreconf..."
autoreconf -iv && {
Expand Down
77 changes: 73 additions & 4 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1476,13 +1476,18 @@ fi
AC_MSG_RESULT([${solarispkg_ips}])
AM_CONDITIONAL(WITH_SOLARIS_PKG_IPS, test x"$solarispkg_ips" = x"yes")

AC_MSG_CHECKING(whether to install systemd files)
dnl Note: Currently there is no automatic detection enabled -
dnl users have to ask they want systemd units installed.
dnl It may be changed based on popular demand to just always
dnl run the "case" below for ${systemdsystemunitdir} values,
dnl like we do for systemdtmpfilesdir further below.
AC_MSG_CHECKING(whether to install systemd unit files)
AC_ARG_WITH([systemdsystemunitdir],
AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files (auto)]),
[
case "${withval}" in
yes|auto|"")
systemdsystemunitdir=`$PKG_CONFIG --variable=systemdsystemunitdir systemd`
systemdsystemunitdir="`$PKG_CONFIG --variable=systemdsystemunitdir systemd`"
;;
no)
systemdsystemunitdir=""
Expand All @@ -1501,15 +1506,53 @@ AM_CONDITIONAL(HAVE_SYSTEMD, test "$systemdsystemunitdir" != "")
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

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)]),
[systemdshutdowndir=${withval}])
dnl Note: this option is enabled only if systemdsystemunitdir is not trivial
if test -n "${systemdsystemunitdir}"; then
case "${systemdshutdowndir}" in
yes|auto|"")
systemdshutdowndir=`$PKG_CONFIG --variable=systemdshutdowndir systemd`
systemdshutdowndir="`$PKG_CONFIG --variable=systemdshutdowndir systemd`"
;;
no)
systemdshutdowndir=""
;;
*)
systemdshutdowndir="${withval}"
;;
esac
fi
if test -n "${systemdshutdowndir}"; then
AC_MSG_RESULT(using ${systemdshutdowndir})
else
AC_MSG_RESULT(no)
fi

dnl Note: if (systemd-)tmpfiles tech is present, it can be useful even for
dnl daemons starting not as systemd units
AC_MSG_CHECKING([whether to install systemd tmpfiles files])
AC_ARG_WITH([systemdtmpfilesdir],
AS_HELP_STRING([--with-systemdtmpfilesdir=DIR], [Directory for systemd tmpfiles scripts (auto)]),
[systemdtmpfilesdir=${withval}])
case "${systemdtmpfilesdir}" in
yes|auto|"")
systemdtmpfilesdir="`$PKG_CONFIG --variable=tmpfilesdir systemd`"
;;
no)
systemdtmpfilesdir=""
;;
*)
systemdtmpfilesdir="${withval}"
;;
esac
if test -n "${systemdtmpfilesdir}"; then
AC_MSG_RESULT(using ${systemdtmpfilesdir})
else
AC_MSG_RESULT(no)
fi

dnl
dnl Tests for CppUnit availability and usability (will be built if we can,
Expand Down Expand Up @@ -1989,6 +2032,7 @@ AC_SUBST(htmldir)
AC_SUBST(pkgconfigdir)
AC_SUBST(systemdsystemunitdir)
AC_SUBST(systemdshutdowndir)
AC_SUBST(systemdtmpfilesdir)
AC_SUBST(auglensdir)
AC_SUBST(hotplugdir)
AC_SUBST(udevdir)
Expand Down Expand Up @@ -2096,9 +2140,33 @@ AS_CASE(["${nut_enable_Werror}"],
)
AC_MSG_RESULT(["${nut_enable_Werror}"])

dnl Finally restore warnings setings that the caller might have provided in CFLAGS etc
dnl Finally restore warnings settings that the caller might have provided in CFLAGS etc
NUT_POP_WARNINGS

dnl Due to possibly repetitive content, generate unique settings:
AS_IF([test -n "$systemdtmpfilesdir"],
[cat > scripts/systemd/nut-common.tmpfiles.in << EOF
# State file (e.g. upsd to driver) and pidfile location for NUT:
d @STATEPATH@/nut 0770 @RUN_AS_USER@ @RUN_AS_GROUP@ - -
X @STATEPATH@/nut
EOF
AS_IF([test "$STATEPATH" != "$PIDPATH"],
[cat >> scripts/systemd/nut-common.tmpfiles.in << EOF
d @PIDPATH@/nut 0770 @RUN_AS_USER@ @RUN_AS_GROUP@ - -
X @PIDPATH@/nut
EOF])
AS_IF([test -n "$ALTPIDPATH" && test "$STATEPATH" != "$ALTPIDPATH" && test "$PIDPATH" != "$ALTPIDPATH"],
[cat >> scripts/systemd/nut-common.tmpfiles.in << EOF
d @ALTPIDPATH@/nut 0770 @RUN_AS_USER@ @RUN_AS_GROUP@ - -
X @ALTPIDPATH@/nut
EOF])
AS_IF([test -n "$ALTSTATEPATH" && test "$STATEPATH" != "$ALTSTATEPATH" && test "$ALTSTATEPATH" != "$ALTPIDPATH" && test "$PIDPATH" != "$ALTSTATEPATH"],
[cat >> scripts/systemd/nut-common.tmpfiles.in << EOF
d @ALTSTATEPATH@/nut 0770 @RUN_AS_USER@ @RUN_AS_GROUP@ - -
X @ALTSTATEPATH@/nut
EOF])
])

AC_OUTPUT([
clients/Makefile
common/Makefile
Expand Down Expand Up @@ -2143,6 +2211,7 @@ AC_OUTPUT([
scripts/upsdrvsvcctl/nut-driver-enumerator.sh
scripts/upsdrvsvcctl/upsdrvsvcctl
scripts/systemd/Makefile
scripts/systemd/nut-common.tmpfiles
scripts/systemd/nut-driver@.service
scripts/systemd/nut-monitor.service
scripts/systemd/nut-server.service
Expand Down
21 changes: 21 additions & 0 deletions docs/configure.txt
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,27 @@ Use --with-systemdsystemunitdir to detect the settings using pkg-config.

Use --with-systemdsystemunitdir=no to disable this feature altogether.

--with-systemdshutdowndir=PATH

Where to install Linux systemd unit definitions for shutdown handling.
Useless and harmless on other OSes, including Linux distributions
without systemd, just adding a little noise to configure script output.

Use --with-systemdshutdowndir to detect the settings using pkg-config.

Use --with-systemdshutdowndir=no to disable this feature altogether.

--with-systemdtmpfilesdir=PATH

Where to install Linux systemd configuration for tmpfiles handling (the
automatically created locations for PID, state and similar run-time files).
Useless and harmless on other OSes, including Linux distributions
without systemd, just adding a little noise to configure script output.

Use --with-systemdtmpfilesdir to detect the settings using pkg-config.

Use --with-systemdtmpfilesdir=no to disable this feature altogether.

--with-augeas-lenses-dir=PATH

Where to install Augeas configuration-management lenses. Only useful and valid
Expand Down
5 changes: 4 additions & 1 deletion docs/nut.dict
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
personal_ws-1.1 en 2608 utf-8
personal_ws-1.1 en 2611 utf-8
AAS
ACFAIL
ACFREQ
Expand Down Expand Up @@ -2371,7 +2371,9 @@ sysconfig
syslog
systemctl
systemd
systemdshutdowndir
systemdsystemunitdir
systemdtmpfilesdir
systemhours
systemmode
systemtest
Expand Down Expand Up @@ -2405,6 +2407,7 @@ timername
tiocm
tios
tmp
tmpfiles
toolchain
toolkits
topbot
Expand Down
3 changes: 3 additions & 0 deletions scripts/systemd/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Note: nut-common.tmpfiles.in is also generated, by configure script
/nut-common.tmpfiles.in
/nut-common.tmpfiles
/nut-driver.service
/nut-driver@.service
/nut-driver.target
Expand Down
6 changes: 5 additions & 1 deletion scripts/systemd/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ systemdsystemunit_DATA = \
nut-driver.target \
nut.target

systemdtmpfiles_DATA = \
nut-common.tmpfiles

EXTRA_DIST += nut-driver.target nut.target

systemdshutdown_SCRIPTS = nutshutdown
Expand All @@ -20,7 +23,8 @@ libexec_SCRIPTS = ../upsdrvsvcctl/nut-driver-enumerator.sh
sbin_SCRIPTS = ../upsdrvsvcctl/upsdrvsvcctl

else
EXTRA_DIST += nut-driver@.service.in nut-monitor.service.in \
EXTRA_DIST += \
nut-common.tmpfiles.in nut-driver@.service.in nut-monitor.service.in \
nut-server.service.in nutshutdown.in nut-driver.target nut.target \
nut-driver-enumerator.path.in nut-driver-enumerator.service.in
endif
Expand Down