diff --git a/src/Makefile.am b/src/Makefile.am index 2140977b..51cd3efa 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -357,8 +357,8 @@ doc/user/custom.xsl doc/user/usermanual.xml \ filters/injectcommon.sh filters/recfiltcommon filters/rcltxtlines.py \ \ index/rclmon.sh \ -index/recollindex-system.service \ -index/recollindex-user.service \ +index/recollindex@.service \ +index/recollindex.service \ \ kde/kioslave/kio_recoll/00README.txt \ kde/kioslave/kio_recoll/CMakeLists.txt \ @@ -654,8 +654,8 @@ defconfdir = $(pkgdatadir)/examples defconf_DATA = \ desktop/recollindex.desktop \ index/rclmon.sh \ -index/recollindex-system.service \ -index/recollindex-user.service \ +index/recollindex@.service \ +index/recollindex.service \ sampleconf/fragbuts.xml \ sampleconf/fields \ sampleconf/recoll.conf \ @@ -749,6 +749,13 @@ filters/xml.xsl \ python/recoll/recoll/conftree.py \ python/recoll/recoll/rclconfig.py +if INSTALL_SYSTEMD_UNITS +systemd_system_unitdir = @SYSTEMD_SYSTEM_UNIT_DIR@ +systemd_user_unitdir = @SYSTEMD_USER_UNIT_DIR@ +systemd_system_unit_DATA = index/recollindex@.service +systemd_user_unit_DATA = index/recollindex.service +endif + install-data-hook: (cd $(DESTDIR)/$(filterdir); \ chmod a+x rcl* ppt-dump.py xls-dump.py xlsxmltocsv.py hotrecoll.py; \ diff --git a/src/configure.ac b/src/configure.ac index 7eb6ebea..e350e410 100644 --- a/src/configure.ac +++ b/src/configure.ac @@ -471,6 +471,46 @@ if test X$enableQT = Xyes ; then ##################### End QT stuff fi +dnl Borrow a macro definition from pkg.config, +dnl for older installs that lack it. +m4_ifndef([PKG_CHECK_VAR], [ +dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE, +dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +dnl ------------------------------------------- +dnl Retrieves the value of the pkg-config variable for the given module. +AC_DEFUN([PKG_CHECK_VAR], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl + +_PKG_CONFIG([$1], [variable="][$3]["], [$2]) +AS_VAR_COPY([$1], [pkg_cv_][$1]) + +AS_VAR_IF([$1], [""], [$5], [$4])dnl +])dnl PKG_CHECK_VAR +]) + +### Systemd +AC_ARG_WITH([systemd], + AC_HELP_STRING([--without-systemd], + [Disable installation of the systemd unit files.])) +AC_ARG_WITH([system-unit-dir], + AC_HELP_STRING([--with-system-unit-dir=DIR], + [Install location for systemd system unit files]), + [SYSTEMD_SYSTEM_UNIT_DIR="$withval"], + [PKG_CHECK_VAR([SYSTEMD_SYSTEM_UNIT_DIR], [systemd], [systemd_system_unit_dir])]) +AC_ARG_WITH([user-unit-dir], + AC_HELP_STRING([--with-user-unit-dir=DIR], + [Install location for systemd user unit files]), + [SYSTEMD_USER_UNIT_DIR="$withval"], + [PKG_CHECK_VAR([SYSTEMD_USER_UNIT_DIR], [systemd], [systemd_user_unit_dir])]) + +if test "x$SYSTEMD_SYSTEM_UNIT_DIR" = "x" -o \ + "x$SYSTEMD_USER_UNIT_DIR" = "x"; then + with_systemd = "no" +fi + +AM_CONDITIONAL([INSTALL_SYSTEMD_UNITS], [test "X$with_systemd" != "Xno"]) + ### X11: this is needed for the session monitoring code (in recollindex -m) AC_ARG_ENABLE(x11mon, AC_HELP_STRING([--disable-x11mon], @@ -532,6 +572,8 @@ AC_SUBST(RCLVERSION) AC_SUBST(RCLLIBVERSION) AC_SUBST(XSLT_CFLAGS) AC_SUBST(XSLT_LIBS) +AC_SUBST([SYSTEMD_SYSTEM_UNIT_DIR]) +AC_SUBST([SYSTEMD_USER_UNIT_DIR]) AC_CONFIG_FILES([Makefile python/recoll/setup.py python/pychm/setup.py]) diff --git a/src/doc/user/usermanual.xml b/src/doc/user/usermanual.xml index 5c9848fe..e3f49673 100644 --- a/src/doc/user/usermanual.xml +++ b/src/doc/user/usermanual.xml @@ -1775,21 +1775,28 @@ metadatacmds = ; tags = tmsu tags %f The installation contains two example files (in share/recoll/examples) for starting the indexing daemon with systemd. - recollindex-user.service would be used for - starting recollindex as a user service, and can be installed with the - following commands: -systemctl --user link /usr/share/recoll/examples/recollindex-user.service -systemctl --user enable --now recollindex-user.service + recollindex.service would be used for + starting recollindex as a user service. The indexer will start when the user logs in and run while there is a session open for them. - recollindex-system.service would be used for starting the indexer - at boot time, running as a specific user. It can be useful when running the text search as a - shared service (e.g. when users access it through the WEB UI). You will need to edit it to - replace the @SOMEUSER@ value with something which makes sense in your case, then install it - as a regular systemd system service. Of course, if you want to - run several such units, you will also need to rename the installed file. +recollindex@.service is a template service which would be used + for starting the indexer at boot time, running as a specific user. It can be useful when +running the text search as a shared service (e.g. when users access it through the WEB UI). + If configured to do so, the unit files should have been installed in your system's + default systemd paths (usually /usr/lib/systemd/system/ and + /usr/lib/systemd/user/). If not, you may need to copy the files there + before starting the service. + + With the unit files installed in the proper location, the user unit can be + started with the following commands: +systemctl --user daemon-reload +systemctl --user enable --now recollindex.service + The system unit file can be enabled for a particular user by running, as root: +systemctl daemon-reload +systemctl enable --now recollindex@username.service + (A valid user name should be substituted for username, of course.) @@ -6443,6 +6450,21 @@ hasextract = False or PHP extensions, but might yield very marginally faster code. + Disable + the automatic installation of systemd unit files. Normally + unit files are installed if the install path can be detected. + + + + Provide + an install path for the systemd system unit template file. + + + + Provide + an install path for the systemd user unit file. + + Of course the usual autoconf configure options, like apply. diff --git a/src/index/recollindex-system.service b/src/index/recollindex-system.service deleted file mode 100644 index fc15075a..00000000 --- a/src/index/recollindex-system.service +++ /dev/null @@ -1,14 +0,0 @@ -[Unit] -Description=Recollindex indexing for @SOMEUSER@ -After=network-online.target -RequiresMountsFor=/home/@SOMEUSER@ - -[Service] -Type=simple -Restart=on-failure -RestartSec=30 -ExecStart=/usr/bin/recollindex -m -D -x -w 10 -c /home/@SOMEUSER@/.recoll -User=@SOMEUSER@ - -[Install] -WantedBy=multi-user.target diff --git a/src/index/recollindex-user.service b/src/index/recollindex.service similarity index 100% rename from src/index/recollindex-user.service rename to src/index/recollindex.service diff --git a/src/index/recollindex@.service b/src/index/recollindex@.service new file mode 100644 index 00000000..51a67a97 --- /dev/null +++ b/src/index/recollindex@.service @@ -0,0 +1,16 @@ +# Instantiate with a username as argument +# e.g. `systemctl enable recollindex@myuser.service` +[Unit] +Description=Recollindex indexing for %i +After=network-online.target +RequiresMountsFor=/home/%i + +[Service] +Type=simple +Restart=on-failure +RestartSec=30 +ExecStart=/usr/bin/recollindex -m -D -x -w 10 -c /home/%i/.recoll +User=%i + +[Install] +WantedBy=multi-user.target