From f3501534d4443a2d241d70291b60be6034761cf1 Mon Sep 17 00:00:00 2001 From: SATOH Fumiyasu Date: Fri, 11 Aug 2017 19:33:32 +0900 Subject: [PATCH] ITS#8707 - Add slapd.service and lloadd.service for systemd --- build/top.mk | 1 + configure.ac | 38 +++++++++++++++---------------- servers/lloadd/Makefile_server.in | 25 ++++++++++++++++++-- servers/lloadd/lloadd.service | 13 +++++++++++ servers/slapd/Makefile.in | 14 ++++++++++-- servers/slapd/back-wt/Makefile.in | 2 +- servers/slapd/slapd.service | 15 ++++++++++++ 7 files changed, 83 insertions(+), 25 deletions(-) create mode 100644 servers/lloadd/lloadd.service create mode 100644 servers/slapd/slapd.service diff --git a/build/top.mk b/build/top.mk index 4b8efb2b96..38ce146d77 100644 --- a/build/top.mk +++ b/build/top.mk @@ -45,6 +45,7 @@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ sysconfdir = @sysconfdir@$(ldap_subdir) schemadir = $(sysconfdir)/schema +systemdsystemunitdir = @systemdsystemunitdir@ PLAT = @PLAT@ EXEEXT = @EXEEXT@ diff --git a/configure.ac b/configure.ac index 9d13f3aa73..6e44acf395 100644 --- a/configure.ac +++ b/configure.ac @@ -33,6 +33,9 @@ dnl OpenLDAP Autoconf Macros builtin(include, build/openldap.m4)dnl dnl ================================================================ +m4_ifndef([PKG_PREREQ], + [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])]) + AC_CONFIG_AUX_DIR(build)dnl AC_CONFIG_MACRO_DIRS([build]) @@ -2006,26 +2009,10 @@ 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]) + PKG_CHECK_MODULES(WT, wiredtiger) + if test $ol_enable_wt = yes ; then + SLAPD_LIBS="$SLAPD_LIBS \$(WT_LIBS)" fi - WT_INCS=`pkg-config --cflags wiredtiger` - WT_LIBS=`pkg-config --libs wiredtiger` - - save_CFLAGS="$CFLAGS" - save_LDFLAGS="$LDFLAGS" - CFLAGS="$WT_INCS" - CPPFLAGS="$WT_INCS" - LDFLAGS="$WT_LIBS" - AC_CHECK_HEADERS([wiredtiger.h]) - AC_CHECK_LIB(wiredtiger,wiredtiger_version,[: ok],[ - AC_MSG_ERROR([could not locate wiredtiger library]) - ]) - CFLAGS="$save_CFLAGS" - CPPFLAGS="$save_CPPFLAGS" - LDFLAGS="$save_LDFLAGS" - SLAPD_LIBS="$SLAPD_LIBS \$(WT_LIBS)" ol_link_wt=yes fi @@ -2091,6 +2078,7 @@ dnl dnl Check for systemd (only if we have a server) dnl WITH_SYSTEMD=no +systemdsystemunitdir= ol_link_systemd=no if test $ol_enable_slapd == no && test $ol_enable_balancer != yes ; then if test $ol_with_systemd != no ; then @@ -2117,8 +2105,18 @@ if test $ol_with_systemd != no ; then AC_DEFINE(HAVE_SYSTEMD,1,[define if you have systemd]) SYSTEMD_LIBS="$ol_link_systemd" WITH_SYSTEMD=yes + + PKG_CHECK_VAR(systemdsystemunitdir, systemd, systemdsystemunitdir) + if test -z "$systemdsystemunitdir"; then + if test -d /usr/lib/systemd/system; then + systemdsystemunitdir=/usr/lib/systemd/system + else + systemdsystemunitdir=/lib/systemd/system + fi + fi fi fi +AC_SUBST(systemdsystemunitdir) dnl ---------------------------------------------------------------- dnl Check for entropy sources @@ -3260,7 +3258,7 @@ AC_SUBST(SLAPD_SQL_LDFLAGS) AC_SUBST(SLAPD_SQL_LIBS) AC_SUBST(SLAPD_SQL_INCLUDES) -AC_SUBST(WT_INCS) +AC_SUBST(WT_CFLAGS) AC_SUBST(WT_LIBS) AC_SUBST(BALANCER_INCLUDE) diff --git a/servers/lloadd/Makefile_server.in b/servers/lloadd/Makefile_server.in index 6964ca5dcc..2e01aa512e 100644 --- a/servers/lloadd/Makefile_server.in +++ b/servers/lloadd/Makefile_server.in @@ -29,7 +29,7 @@ OBJS = $(patsubst %.c,%.o,$(SRCS)) $(@PLAT@_OBJS) BUILD_OPT = "--enable-balancer" BUILD_SRV = @BUILD_BALANCER@ -all-local-srv: $(PROGRAMS) +all-local-srv: $(PROGRAMS) all-cffiles # $(LTHREAD_LIBS) must be last! XLIBS = $(LLOADD_L) @@ -58,7 +58,19 @@ version.c: Makefile version.o: version.c $(OBJS) $(LLOADD_L) -install-local-srv: FORCE +all-cffiles: + @if test -n "$(systemdsystemunitdir)"; then \ + $(SED) -e "s;%LIBEXECDIR%;$(libexecdir);" \ + $(srcdir)/lloadd.service > lloadd.service.tmp ; \ + fi + touch all-cffiles + +clean-local-srv: FORCE + $(RM) *.tmp all-cffiles + +install-local-srv: install-lloadd install-conf + +install-lloadd: FORCE -$(MKDIR) $(DESTDIR)$(libexecdir) @-$(INSTALL) -m 700 -d $(DESTDIR)$(localstatedir)/openldap-lloadd @( \ @@ -67,3 +79,12 @@ install-local-srv: FORCE $(DESTDIR)$(libexecdir); \ done \ ) + +install-conf: FORCE + @-$(MKDIR) $(DESTDIR)$(sysconfdir) + if test -n "$(systemdsystemunitdir)" && test ! -f $(DESTDIR)$(systemdsystemunitdir)/lloadd.service; then \ + $(MKDIR) $(DESTDIR)$(systemdsystemunitdir); \ + echo "installing lloadd.service in $(systemdsystemunitdir)"; \ + echo "$(INSTALL) $(INSTALLFLAGS) -m 644 lloadd.service.tmp $(DESTDIR)$(systemdsystemunitdir)/lloadd.service"; \ + $(INSTALL) $(INSTALLFLAGS) -m 644 lloadd.service.tmp $(DESTDIR)$(systemdsystemunitdir)/lloadd.service; \ + fi diff --git a/servers/lloadd/lloadd.service b/servers/lloadd/lloadd.service new file mode 100644 index 0000000000..062b8caa7d --- /dev/null +++ b/servers/lloadd/lloadd.service @@ -0,0 +1,13 @@ +[Unit] +Description=LDAP Load Balancer Daemon +After=syslog.target network-online.target +Documentation=man:lloadd.conf + +[Service] +Type=notify +Environment="LLOADD_URLS=ldap:/// ldapi:///" "LLOADD_OPTIONS=" +EnvironmentFile=/etc/sysconfig/lloadd +ExecStart=%LIBEXECDIR%/lloadd -d 0 -h ${LLOADD_URLS} $LLOADD_OPTIONS + +[Install] +WantedBy=multi-user.target diff --git a/servers/slapd/Makefile.in b/servers/slapd/Makefile.in index cf58cda4f2..0a3c36de43 100644 --- a/servers/slapd/Makefile.in +++ b/servers/slapd/Makefile.in @@ -401,11 +401,15 @@ all-cffiles: slapd $(SLAPD_DYNAMIC_BACKENDS) dynamic_overlays dynamic_pwmods $(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 @@ -439,6 +443,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) diff --git a/servers/slapd/back-wt/Makefile.in b/servers/slapd/back-wt/Makefile.in index 1cd2222104..4f1f33bcc2 100644 --- a/servers/slapd/back-wt/Makefile.in +++ b/servers/slapd/back-wt/Makefile.in @@ -34,7 +34,7 @@ BUILD_OPT = "--enable-wt" BUILD_MOD = @BUILD_WT@ mod_DEFS = -DSLAPD_IMPORT -MOD_DEFS = @WT_INCS@ +MOD_DEFS = @WT_CFLAGS@ MOD_LIBS = @WT_LIBS@ diff --git a/servers/slapd/slapd.service b/servers/slapd/slapd.service new file mode 100644 index 0000000000..a0599b8e25 --- /dev/null +++ b/servers/slapd/slapd.service @@ -0,0 +1,15 @@ +[Unit] +Description=OpenLDAP Server Daemon +After=syslog.target network-online.target +Documentation=man:slapd +Documentation=man:slapd-config +Documentation=man:slapd-mdb + +[Service] +Type=notify +Environment="SLAPD_URLS=ldap:/// ldapi:///" "SLAPD_OPTIONS=" +EnvironmentFile=/etc/sysconfig/slapd +ExecStart=%LIBEXECDIR%/slapd -d 0 -h ${SLAPD_URLS} $SLAPD_OPTIONS + +[Install] +WantedBy=multi-user.target