Skip to content

Commit

Permalink
Added support for systemd.
Browse files Browse the repository at this point in the history
Based on patch by Christophe Fergeau
  • Loading branch information
sirainen committed Nov 17, 2010
1 parent 71c5cba commit f6ba2de
Show file tree
Hide file tree
Showing 10 changed files with 809 additions and 7 deletions.
14 changes: 14 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ dovecot-config: dovecot-config.in Makefile
-e "s|^\(dovecot_moduledir\)=|\1=$(moduledir)|" \
> dovecot-config

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

systemdsystemunit_DATA = \
dovecot.socket \
dovecot.service
else
EXTRA_DIST += dovecot.socket dovecot.service.in
endif

install-exec-hook:
rm $(DESTDIR)$(pkglibdir)/dovecot-config && \
grep -v '^LIBDOVECOT_.*_INCLUDE' dovecot-config | \
Expand All @@ -62,6 +73,9 @@ install-exec-hook:
> $(DESTDIR)$(pkglibdir)/dovecot-config

CLEANFILES = $(datafiles)
if HAVE_SYSTEMD
CLEANFILES += $systedmsystemunit_DATA
endif

DISTCLEANFILES = $(top_builddir)/dovecot-version.h

Expand Down
9 changes: 9 additions & 0 deletions configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -2629,6 +2629,15 @@ fi
AC_SUBST(RUN_TEST)
AC_SUBST(abs_top_builddir)

AC_ARG_WITH([systemdsystemunitdir],
AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files]),
[], [with_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)])
if test "x$with_systemdsystemunitdir" != xno; then
AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])
AC_DEFINE(HAVE_SYSTEMD,, Define if you want to use systemd socket activation)
fi
AM_CONDITIONAL(HAVE_SYSTEMD, [test -n "$with_systemdsystemunitdir" -a "x$with_systemdsystemunitdir" != xno ])

AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([
Makefile
Expand Down
8 changes: 8 additions & 0 deletions dovecot.service.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[Unit]
Description=Dovecot IMAP/POP3 email server
After=local-fs.target network.target

[Service]
Type=simple
ExecStart=@sbindir@/dovecot -F
NonBlocking=yes
15 changes: 15 additions & 0 deletions dovecot.socket
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[Unit]
Description=Dovecot IMAP/POP3 email server activation socket

[Socket]
#dovecot expects separate IPv4 and IPv6 sockets
BindIPv6Only=ipv6-only
ListenStream=0.0.0.0:143
ListenStream=[::]:143
ListenStream=0.0.0.0:993
ListenStream=[::]:993
KeepAlive=true

[Install]
WantedBy=sockets.target

4 changes: 4 additions & 0 deletions src/lib-master/master-service.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,10 @@ void master_service_env_clean(bool preserve_home)
"TZ",
#ifdef DEBUG
"GDB",
#endif
#ifdef HAVE_SYSTEMD
"LISTEN_PID",
"LISTEN_FDS",
#endif
NULL
};
Expand Down
10 changes: 9 additions & 1 deletion src/master/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ pkglibexecdir = $(libexecdir)/dovecot

sbin_PROGRAMS = dovecot

if HAVE_SYSTEMD
SYSTEMD_SOURCES = sd-daemon.c
endif


AM_CPPFLAGS = \
-I$(top_srcdir)/src/lib \
-I$(top_srcdir)/src/lib-settings \
Expand All @@ -27,17 +32,20 @@ dovecot_SOURCES = \
service-monitor.c \
service-process.c \
service-process-notify.c \
service.c
service.c \
$(SYSTEMD_SOURCES)

noinst_HEADERS = \
capabilities.h \
common.h \
dup2-array.h \
master-settings.h \
sd-daemon.h \
service-anvil.h \
service-listen.h \
service-log.h \
service-monitor.h \
service-process.h \
service-process-notify.h \
service.h

4 changes: 4 additions & 0 deletions src/master/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,10 @@ int main(int argc, char *argv[])
static const char *preserve_envs[] = {
/* AIX depends on TZ to get the timezone correctly. */
"TZ",
#ifdef HAVE_SYSTEMD
"LISTEN_PID",
"LISTEN_FDS",
#endif
NULL
};
struct master_settings *set;
Expand Down
Loading

0 comments on commit f6ba2de

Please sign in to comment.