Skip to content

Commit

Permalink
Add slapd.service for systemd
Browse files Browse the repository at this point in the history
  • Loading branch information
fumiyas committed Aug 11, 2017
1 parent cb63247 commit 17fc7f2
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 7 deletions.
1 change: 1 addition & 0 deletions build/top.mk
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@$(ldap_subdir)
schemadir = $(sysconfdir)/schema
systemdsystemunitdir = @systemdsystemunitdir@

PLAT = @PLAT@
EXEEXT = @EXEEXT@
Expand Down
24 changes: 19 additions & 5 deletions configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,7 @@ fi
AC_LIBTOOL_WIN32_DLL
AC_LIBTOOL_DLOPEN
AC_PROG_LIBTOOL
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)

dnl ----------------------------------------------------------------
dnl Perl
Expand Down Expand Up @@ -2107,12 +2108,13 @@ dnl ----------------------------------------------------------------
dnl WiredTiger
ol_link_wt=no
if test $ol_enable_wt != no ; then
AC_CHECK_PROG(PKGCONFIG,pkg-config,yes)
if test "$PKGCONFIG" != yes ; then
AC_MSG_ERROR([could not locate pkg-config])
if test "$PKG_CONFIG" != no; then
WT_INCS=`$PKG_CONFIG --cflags wiredtiger`
WT_LIBS=`$PKG_CONFIG --libs wiredtiger`
else
WT_INCS=
WT_LIBS="-lwiredtiger"
fi
WT_INCS=`pkg-config --cflags wiredtiger`
WT_LIBS=`pkg-config --libs wiredtiger`

save_CFLAGS="$CFLAGS"
save_LDFLAGS="$LDFLAGS"
Expand Down Expand Up @@ -2200,6 +2202,7 @@ dnl
dnl Check for systemd
dnl
WITH_SYSTEMD=no
systemdsystemunitdir=
ol_link_systemd=no
if test $ol_with_systemd != no ; then
AC_CHECK_HEADERS(systemd/sd-daemon.h)
Expand All @@ -2223,6 +2226,17 @@ if test $ol_with_systemd != no ; then
fi
fi

if test $WITH_SYSTEMD = yes; then
if test "$PKG_CONFIG" != no ; then
systemdsystemunitdir=`$PKG_CONFIG --variable=systemdsystemunitdir systemd`
elif test -d /usr/lib/systemd/system; then
systemdsystemunitdir=/usr/lib/systemd/system
else
systemdsystemunitdir=/lib/systemd/system
fi
fi
AC_SUBST(systemdsystemunitdir)

dnl ----------------------------------------------------------------
dnl Check for entropy sources
if test $cross_compiling != yes && test "$ac_cv_mingw32" != yes ; then
Expand Down
14 changes: 12 additions & 2 deletions servers/slapd/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -404,11 +404,15 @@ all-cffiles: slapd $(SLAPD_DYNAMIC_BACKENDS) dynamic_overlays
$(SED) -e "s;%SYSCONFDIR%;$$sysconfdir;" \
-e "s;%LOCALSTATEDIR%;$$localstatedir;" \
-e "s;%MODULEDIR%;$$moduledir;" \
$(srcdir)/slapd.conf > slapd.conf.tmp ; \
$(srcdir)/slapd.conf > slapd.conf.tmp || exit $$?; \
$(SED) -e "s;%SYSCONFDIR%;$$sysconfdir;" \
-e "s;%LOCALSTATEDIR%;$$localstatedir;" \
-e "s;%MODULEDIR%;$$moduledir;" \
$(srcdir)/slapd.ldif > slapd.ldif.tmp ; \
$(srcdir)/slapd.ldif > slapd.ldif.tmp || exit $$?
if test -n "$(systemdsystemunitdir)"; then \
$(SED) -e "s;%LIBEXECDIR%;$(libexecdir);" \
$(srcdir)/slapd.service > slapd.service.tmp ; \
fi
touch all-cffiles

install-schema: FORCE
Expand Down Expand Up @@ -442,6 +446,12 @@ install-conf: FORCE
else \
echo "PRESERVING EXISTING CONFIGURATION FILE $(DESTDIR)$(sysconfdir)/slapd.ldif" ; \
fi
if test -n "$(systemdsystemunitdir)" && test ! -f $(DESTDIR)$(systemdsystemunitdir)/slapd.service; then \
$(MKDIR) $(DESTDIR)$(systemdsystemunitdir); \
echo "installing slapd.service in $(systemdsystemunitdir)"; \
echo "$(INSTALL) $(INSTALLFLAGS) -m 644 slapd.service.tmp $(DESTDIR)$(systemdsystemunitdir)/slapd.service"; \
$(INSTALL) $(INSTALLFLAGS) -m 644 slapd.service.tmp $(DESTDIR)$(systemdsystemunitdir)/slapd.service; \
fi

install-db-config: FORCE
@-$(MKDIR) $(DESTDIR)$(localstatedir) $(DESTDIR)$(sysconfdir)
Expand Down
11 changes: 11 additions & 0 deletions servers/slapd/slapd.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description=OpenLDAP Server
After=syslog.target network-online.target
Documentation=man:slapd

[Service]
Type=notify
ExecStart=%LIBEXECDIR%/slapd -d 0 -h "ldapi:/// ldap:///"

[Install]
WantedBy=multi-user.target

0 comments on commit 17fc7f2

Please sign in to comment.