diff --git a/Makefile.am b/Makefile.am index 9b1ea290c8..1db0506ab8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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' \ diff --git a/autogen.sh b/autogen.sh index 83367f3286..99d8a9bf96 100755 --- a/autogen.sh +++ b/autogen.sh @@ -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 && { diff --git a/configure.ac b/configure.ac index 51dad7111e..f641797f2f 100644 --- a/configure.ac +++ b/configure.ac @@ -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="" @@ -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, @@ -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) @@ -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 @@ -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 diff --git a/docs/configure.txt b/docs/configure.txt index e8530c6469..5b16676f50 100644 --- a/docs/configure.txt +++ b/docs/configure.txt @@ -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 diff --git a/docs/nut.dict b/docs/nut.dict index 7401c79413..0bbac024fe 100644 --- a/docs/nut.dict +++ b/docs/nut.dict @@ -1,4 +1,4 @@ -personal_ws-1.1 en 2608 utf-8 +personal_ws-1.1 en 2611 utf-8 AAS ACFAIL ACFREQ @@ -2371,7 +2371,9 @@ sysconfig syslog systemctl systemd +systemdshutdowndir systemdsystemunitdir +systemdtmpfilesdir systemhours systemmode systemtest @@ -2405,6 +2407,7 @@ timername tiocm tios tmp +tmpfiles toolchain toolkits topbot diff --git a/scripts/systemd/.gitignore b/scripts/systemd/.gitignore index a08b94f5ef..aca233407d 100644 --- a/scripts/systemd/.gitignore +++ b/scripts/systemd/.gitignore @@ -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 diff --git a/scripts/systemd/Makefile.am b/scripts/systemd/Makefile.am index c7c7a9f3c9..4e8303828f 100644 --- a/scripts/systemd/Makefile.am +++ b/scripts/systemd/Makefile.am @@ -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 @@ -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