Merge branch 'systemd-install' into 'master'

Systemd install

See merge request medoc92/recoll!7
This commit is contained in:
Jean-Francois Dockes 2021-07-02 15:20:36 +00:00
commit 00987509f8
6 changed files with 102 additions and 29 deletions

View File

@ -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; \

View File

@ -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])

View File

@ -1775,21 +1775,28 @@ metadatacmds = ; <replaceable>tags</replaceable> = tmsu tags %f
<para>The installation contains two example files
(in <filename>share/recoll/examples</filename>) for starting the indexing daemon with
<application>systemd</application>.</para>
<para><filename>recollindex-user.service</filename> would be used for
starting <command>recollindex</command> as a user service, and can be installed with the
following commands:
<programlisting>systemctl --user link /usr/share/recoll/examples/recollindex-user.service
systemctl --user enable --now recollindex-user.service</programlisting>
<para><filename>recollindex.service</filename> would be used for
starting <command>recollindex</command> as a user service.
The indexer will start when the user logs in and run while there is a session open for
them.</para>
<para><filename>recollindex-system.service</filename> 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 <application>systemd</application> system service. Of course, if you want to
run several such units, you will also need to rename the installed file.</para>
<para><filename>recollindex@.service</filename> 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).</para>
<para>If configured to do so, the unit files should have been installed in your system's
default systemd paths (usually <filename>/usr/lib/systemd/system/</filename> and
<filename>/usr/lib/systemd/user/</filename>). If not, you may need to copy the files there
before starting the service.</para>
<para>With the unit files installed in the proper location, the user unit can be
started with the following commands:
<programlisting>systemctl --user daemon-reload
systemctl --user enable --now recollindex.service</programlisting>
The system unit file can be enabled for a particular user by running, as root:
<programlisting>systemctl daemon-reload
systemctl enable --now recollindex@<varname>username</varname>.service</programlisting>
(A valid user name should be substituted for <varname>username</varname>, of course.)</para>
</simplesect>
<simplesect id="RCL.INDEXING.MONITOR.START">
@ -6443,6 +6450,21 @@ hasextract = False
or <application>PHP</application> extensions, but might
yield very marginally faster code.</para></listitem>
<listitem><para><option>--without-systemd</option> Disable
the automatic installation of systemd unit files. Normally
unit files are installed if the install path can be detected.
</para></listitem>
<listitem><para>
<option>--with-system-unit-dir=DIR</option> Provide
an install path for the systemd system unit template file.
</para></listitem>
<listitem><para>
<option>--with-user-unit-dir=DIR</option> Provide
an install path for the systemd user unit file.
</para></listitem>
<listitem><para>Of course the usual
<application>autoconf</application> <command>configure</command>
options, like <option>--prefix</option> apply.</para>

View File

@ -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

View File

@ -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