Skip to content

Commit

Permalink
master: Use libsystemd instead of local source
Browse files Browse the repository at this point in the history
  • Loading branch information
cmouse committed Mar 3, 2021
1 parent 19e05ad commit a42bb36
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 734 deletions.
4 changes: 2 additions & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ dovecot-config: dovecot-config.in Makefile
-e "s|^\(dovecot_statedir\)=|\1=$(statedir)|" \
) > dovecot-config

if HAVE_SYSTEMD
if HAVE_LIBSYSTEMD
%.service: %.service.in
$(AM_V_GEN)sed -e 's,@sbindir\@,$(sbindir),g' -e 's,@bindir\@,$(bindir),g' -e 's,@rundir\@,$(rundir),g' $< > $@

Expand Down Expand Up @@ -87,7 +87,7 @@ install-exec-hook:
uninstall-hook:
rm $(DESTDIR)$(pkglibdir)/dovecot-config

if HAVE_SYSTEMD
if HAVE_LIBSYSTEMD
CLEANFILES = dovecot.service
endif

Expand Down
31 changes: 18 additions & 13 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -239,19 +239,24 @@ AS_HELP_STRING([--with-statedir=DIR], [Permanent data directory (LOCALSTATEDIR/l
)
AC_SUBST(statedir)

AC_ARG_WITH([systemdsystemunitdir],
AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files (auto=detect)]), [
if test "$withval" = "auto"; then
systemdsystemunitdir=`$PKG_CONFIG --variable=systemdsystemunitdir systemd`
elif test "$withval" != "no"; then
systemdsystemunitdir=$withval
fi
], [])
if test "$systemdsystemunitdir" != ""; then
AC_SUBST(systemdsystemunitdir)
AC_DEFINE(HAVE_SYSTEMD,, [Define if you want to use systemd socket activation])
fi
AM_CONDITIONAL(HAVE_SYSTEMD, test "$systemdsystemunitdir" != "")
AC_ARG_WITH([systemd],
AS_HELP_STRING([--with-systemd], [Build with systemd support (default=auto)]),
want_systemd="$withval"
)

AS_IF([test "$want_systemd" != "no"], [
PKG_CHECK_MODULES([SYSTEMD], [libsystemd], [
AC_DEFINE([HAVE_LIBSYSTEMD],[1], [Define to 1 if you have libsystemd])
systemdsystemunitdir=`$PKG_CONFIG --variable=systemdsystemunitdir systemd`
], [AS_IF([test "$want_systemd" = "yes"], [
AC_MSG_ERROR([libsystemd not found])
],
[want_systemd="no"])
])
])

AC_SUBST(systemdsystemunitdir)
AM_CONDITIONAL(HAVE_LIBSYSTEMD, [test "$want_systemd" != "no"])

dovecot_moduledir="$libdir/dovecot"
DC_DOVECOT_MODULEDIR
Expand Down
2 changes: 1 addition & 1 deletion src/lib-master/master-service-settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ static const struct setting_define master_service_setting_defines[] = {
};

/* <settings checks> */
#ifdef HAVE_SYSTEMD
#ifdef HAVE_LIBSYSTEMD
# define ENV_SYSTEMD " LISTEN_PID LISTEN_FDS NOTIFY_SOCKET"
#else
# define ENV_SYSTEMD ""
Expand Down
11 changes: 3 additions & 8 deletions src/master/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
pkglibexecdir = $(libexecdir)/dovecot

sbin_PROGRAMS = dovecot

if HAVE_SYSTEMD
SYSTEMD_SOURCES = sd-daemon.c
endif

systemd_lib =

AM_CPPFLAGS = \
-I$(top_srcdir)/src/lib \
Expand All @@ -20,6 +16,7 @@ AM_CPPFLAGS = \
$(BINARY_CFLAGS)

dovecot_LDADD = \
$(SYSTEMD_LIBS) \
$(LIBCAP) \
$(LIBDOVECOT) \
$(BINARY_LDFLAGS)
Expand All @@ -38,16 +35,14 @@ dovecot_SOURCES = \
service-monitor.c \
service-process.c \
service-process-notify.c \
service.c \
$(SYSTEMD_SOURCES)
service.c

noinst_HEADERS = \
capabilities.h \
common.h \
dup2-array.h \
master-client.h \
master-settings.h \
sd-daemon.h \
service-anvil.h \
service-listen.h \
service-log.h \
Expand Down
6 changes: 3 additions & 3 deletions src/master/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
#include "service-process.h"
#include "service-log.h"
#include "dovecot-version.h"
#ifdef HAVE_SYSTEMD
# include "sd-daemon.h"
#ifdef HAVE_LIBSYSTEMD
# include <systemd/sd-daemon.h>
#endif

#include <stdio.h>
Expand Down Expand Up @@ -548,7 +548,7 @@ static void main_init(const struct master_settings *set)
master_clients_init();

services_monitor_start(services);
#ifdef HAVE_SYSTEMD
#ifdef HAVE_LIBSYSTEMD
sd_notify(0, "READY=1");
#endif
startup_finished = TRUE;
Expand Down

0 comments on commit a42bb36

Please sign in to comment.