Make systemd units installable

This commit is contained in:
FeRD (Frank Dana) 2021-07-01 21:18:48 -04:00
parent 2a92200012
commit a1f78ba57c
5 changed files with 69 additions and 18 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

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