1
0
Эх сурвалжийг харах

Bug 695736 - Providing native systemd file for upcoming F15 Feature Systemd

https://bugzilla.redhat.com/show_bug.cgi?id=695736
Resolves: bug 695736
Bug Description: Providing native systemd file for upcoming F15 Feature Systemd
Reviewed by: nhosoi, nkinder (Thanks!)
Branch: master
Fix Description: Since we support multiple instances of directory server,
create a dirsrv.target, and have the instances "want" that target.  There
is a service template file [email protected] that supports replaceable
parameters which are instance specific.  When a new instance is created,
we create a symlink called dirsrv@$instance.service which links to the
template file.  systemd fills in the %i with the correct instance name.
The service command will not work.  You have to use the systemctl command:
systemctl stop [email protected] - single instance
systemctl stop dirsrv.target - all instances
There are still some outstanding issues with systemd:
* systemctl restart dirsrv.target - will hang after shutting down the
instances
When using systemd, have to use the systemctl start command in startServer
or other systemd commands like status, restart, stop will not work
Note: the "group" name dirsrv.target is flexible - just change the
--with-systemdgroupname=NAME when running configure
Platforms tested: Fedora 16 x86_64
Flag Day: yes
Doc impact: yes
Rich Megginson 14 жил өмнө
parent
commit
144c607fa2

+ 46 - 4
Makefile.am

@@ -132,6 +132,9 @@ schemadir = $(sysconfdir)@schemadir@
 serverdir = $(libdir)@serverdir@
 serverplugindir = $(libdir)@serverplugindir@
 taskdir = $(datadir)@scripttemplatedir@
+systemdsystemunitdir = @with_systemdsystemunitdir@
+systemdsystemconfdir = @with_systemdsystemconfdir@
+systemdgroupname = @with_systemdgroupname@
 initdir = @initdir@
 initconfigdir = $(sysconfdir)@initconfigdir@
 instconfigdir = @instconfigdir@
@@ -374,8 +377,15 @@ task_SCRIPTS = ldap/admin/src/scripts/template-bak2db \
 	ldap/admin/src/scripts/template-verify-db.pl \
 	ldap/admin/src/scripts/template-dbverify
 
+if SYSTEMD
+# yes, that is an @ in the filename . . .
+systemdsystemunit_DATA = wrappers/$(PACKAGE_NAME)@.service \
+	wrappers/$(systemdgroupname) \
+	wrappers/$(PACKAGE_NAME)-snmp.service
+else
 init_SCRIPTS = wrappers/$(PACKAGE_NAME) \
 	wrappers/$(PACKAGE_NAME)-snmp
+endif
 
 initconfig_DATA = ldap/admin/src/$(PACKAGE_NAME)
 
@@ -1421,7 +1431,10 @@ fixupcmd = sed \
 	-e 's,@initconfigdir\@,$(initconfigdir),g'\
 	-e 's,@updatedir\@,$(updatedir),g' \
 	-e 's,@ldaplib\@,$(ldaplib),g' \
-	-e 's,@ldaplib_defs\@,$(ldaplib_defs),g'
+	-e 's,@ldaplib_defs\@,$(ldaplib_defs),g' \
+	-e 's,@systemdsystemunitdir\@,$(systemdsystemunitdir),g' \
+	-e 's,@systemdsystemconfdir\@,$(systemdsystemconfdir),g' \
+	-e 's,@systemdgroupname\@,$(systemdgroupname),g'
 else
 fixupcmd = sed \
 	-e 's,@bindir\@,$(bindir),g' \
@@ -1484,7 +1497,10 @@ fixupcmd = sed \
 	-e 's,@initconfigdir\@,$(initconfigdir),g' \
 	-e 's,@updatedir\@,$(updatedir),g' \
 	-e 's,@ldaplib\@,$(ldaplib),g' \
-	-e 's,@ldaplib_defs\@,$(ldaplib_defs),g'
+	-e 's,@ldaplib_defs\@,$(ldaplib_defs),g' \
+	-e 's,@systemdsystemunitdir\@,$(systemdsystemunitdir),g' \
+	-e 's,@systemdsystemconfdir\@,$(systemdsystemconfdir),g' \
+	-e 's,@systemdgroupname\@,$(systemdgroupname),g'
 endif
 
 %: %.in
@@ -1495,9 +1511,22 @@ endif
 	if [ ! -d $(dir $@) ] ; then mkdir -p $(dir $@) ; fi
 	$(fixupcmd) $^ > $@
 
-%/$(PACKAGE_NAME): %/initconfig.in
+%/$(PACKAGE_NAME): %/base-initconfig.in
 	if [ ! -d $(dir $@) ] ; then mkdir -p $(dir $@) ; fi
-	$(fixupcmd) $^ > $@
+if SYSTEMD
+	$(fixupcmd) $^ | sed -e 's/@preamble@/# This file is in systemd EnvironmentFile format - see man systemd.exec/' > $@
+else
+	$(fixupcmd) $^ | sed -n -e 's/@preamble@//' -e '/^#/{p;d}' -e '/^$$/{p;d}' -e 's/^\([^=]*\)\(=.*\)$$/\1\2 ; export \1/ ; p' > $@
+	$(fixupcmd) $(srcdir)/ldap/admin/src/initconfig.in >> $@
+endif
+
+%/template-initconfig: %/template-initconfig.in
+	if [ ! -d $(dir $@) ] ; then mkdir -p $(dir $@) ; fi
+if SYSTEMD
+	$(fixupcmd) $^ | sed -e 's/@preamble@/# This file is in systemd EnvironmentFile format - see man systemd.exec/' > $@
+else
+	$(fixupcmd) $^ | sed -n -e 's/@preamble@//' -e '/^#/{p;d}' -e '/^$$/{p;d}' -e 's/^\([^=]*\)\(=.*\)$$/\1\2 ; export \1/ ; p' > $@
+endif
 
 %/$(PACKAGE_NAME).pc: %/dirsrv.pc.in
 	if [ ! -d $(dir $@) ] ; then mkdir -p $(dir $@) ; fi
@@ -1507,6 +1536,19 @@ endif
 	if [ ! -d $(dir $@) ] ; then mkdir -p $(dir $@) ; fi
 	$(fixupcmd) $^ > $@
 
+# yes, that is an @ in the filename . . .
+%/$(PACKAGE_NAME)@.service: %/systemd.template.service.in
+	if [ ! -d $(dir $@) ] ; then mkdir -p $(dir $@) ; fi
+	$(fixupcmd) $^ > $@
+
+%/$(systemdgroupname): %/systemd.group.in
+	if [ ! -d $(dir $@) ] ; then mkdir -p $(dir $@) ; fi
+	$(fixupcmd) $^ > $@
+
+%/$(PACKAGE_NAME)-snmp.service: %/systemd-snmp.service.in
+	if [ ! -d $(dir $@) ] ; then mkdir -p $(dir $@) ; fi
+	$(fixupcmd) $^ > $@
+
 # if distdir is a git tag, use that for the git archive tag, else
 # just assume a developer build and use HEAD
 git-archive:

+ 78 - 16
Makefile.in

@@ -123,7 +123,8 @@ am__installdirs = "$(DESTDIR)$(serverdir)" \
 	"$(DESTDIR)$(propertydir)" "$(DESTDIR)$(perldir)" \
 	"$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(propertydir)" \
 	"$(DESTDIR)$(sampledatadir)" "$(DESTDIR)$(schemadir)" \
-	"$(DESTDIR)$(updatedir)" "$(DESTDIR)$(serverincdir)"
+	"$(DESTDIR)$(systemdsystemunitdir)" "$(DESTDIR)$(updatedir)" \
+	"$(DESTDIR)$(serverincdir)"
 LTLIBRARIES = $(server_LTLIBRARIES) $(serverplugin_LTLIBRARIES)
 am__DEPENDENCIES_1 =
 libacctpolicy_plugin_la_DEPENDENCIES = libslapd.la \
@@ -1051,7 +1052,7 @@ MANS = $(dist_man_MANS)
 DATA = $(config_DATA) $(inf_DATA) $(initconfig_DATA) $(mib_DATA) \
 	$(nodist_property_DATA) $(perl_DATA) $(pkgconfig_DATA) \
 	$(property_DATA) $(sampledata_DATA) $(schema_DATA) \
-	$(update_DATA)
+	$(systemdsystemunit_DATA) $(update_DATA)
 HEADERS = $(serverinc_HEADERS)
 ETAGS = etags
 CTAGS = ctags
@@ -1135,7 +1136,6 @@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
 PACKAGE_NAME = @PACKAGE_NAME@
 PACKAGE_STRING = @PACKAGE_STRING@
 PACKAGE_TARNAME = @PACKAGE_TARNAME@
-PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_SEPARATOR = @PATH_SEPARATOR@
 PKG_CONFIG = @PKG_CONFIG@
@@ -1216,6 +1216,7 @@ libdir = @libdir@
 libexecdir = @libexecdir@
 localedir = @localedir@
 localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
 mandir = @mandir@
 mibdir = $(datadir)@mibdir@
 mkdir_p = @mkdir_p@
@@ -1271,6 +1272,9 @@ updatedir = $(datadir)@updatedir@
 vendor = @vendor@
 with_fhs_opt = @with_fhs_opt@
 with_selinux = @with_selinux@
+with_systemdgroupname = @with_systemdgroupname@
+with_systemdsystemconfdir = @with_systemdsystemconfdir@
+with_systemdsystemunitdir = @with_systemdsystemunitdir@
 with_tmpfiles_d = @with_tmpfiles_d@
 
 # look for included m4 files in the ./m4/ directory
@@ -1373,6 +1377,9 @@ CLEANFILES = dberrstrs.h ns-slapd.properties \
 	ldap/ldif/template-state.ldif ldap/ldif/template-suffix-db.ldif
 
 taskdir = $(datadir)@scripttemplatedir@
+systemdsystemunitdir = @with_systemdsystemunitdir@
+systemdsystemconfdir = @with_systemdsystemconfdir@
+systemdgroupname = @with_systemdgroupname@
 pkgconfigdir = $(libdir)/pkgconfig
 server_LTLIBRARIES = libslapd.la libns-dshttpd.la
 
@@ -1576,8 +1583,14 @@ task_SCRIPTS = ldap/admin/src/scripts/template-bak2db \
 	ldap/admin/src/scripts/template-verify-db.pl \
 	ldap/admin/src/scripts/template-dbverify
 
-init_SCRIPTS = wrappers/$(PACKAGE_NAME) \
-	wrappers/$(PACKAGE_NAME)-snmp
+
+# yes, that is an @ in the filename . . .
+@SYSTEMD_TRUE@systemdsystemunit_DATA = wrappers/$(PACKAGE_NAME)@.service \
+@SYSTEMD_TRUE@	wrappers/$(systemdgroupname) \
+@SYSTEMD_TRUE@	wrappers/$(PACKAGE_NAME)-snmp.service
+
+@SYSTEMD_FALSE@init_SCRIPTS = wrappers/$(PACKAGE_NAME) \
+@SYSTEMD_FALSE@	wrappers/$(PACKAGE_NAME)-snmp
 
 initconfig_DATA = ldap/admin/src/$(PACKAGE_NAME)
 inf_DATA = ldap/admin/src/slapd.inf \
@@ -2526,7 +2539,10 @@ rsearch_bin_LDADD = $(NSPR_LINK) $(NSS_LINK) $(LDAPSDK_LINK) $(SASL_LINK) $(LIBS
 @BUNDLE_FALSE@	-e 's,@initconfigdir\@,$(initconfigdir),g' \
 @BUNDLE_FALSE@	-e 's,@updatedir\@,$(updatedir),g' \
 @BUNDLE_FALSE@	-e 's,@ldaplib\@,$(ldaplib),g' \
-@BUNDLE_FALSE@	-e 's,@ldaplib_defs\@,$(ldaplib_defs),g'
+@BUNDLE_FALSE@	-e 's,@ldaplib_defs\@,$(ldaplib_defs),g' \
+@BUNDLE_FALSE@	-e 's,@systemdsystemunitdir\@,$(systemdsystemunitdir),g' \
+@BUNDLE_FALSE@	-e 's,@systemdsystemconfdir\@,$(systemdsystemconfdir),g' \
+@BUNDLE_FALSE@	-e 's,@systemdgroupname\@,$(systemdgroupname),g'
 
 
 # these are for the config files and scripts that we need to generate and replace
@@ -2599,7 +2615,10 @@ rsearch_bin_LDADD = $(NSPR_LINK) $(NSS_LINK) $(LDAPSDK_LINK) $(SASL_LINK) $(LIBS
 @BUNDLE_TRUE@	-e 's,@initconfigdir\@,$(initconfigdir),g'\
 @BUNDLE_TRUE@	-e 's,@updatedir\@,$(updatedir),g' \
 @BUNDLE_TRUE@	-e 's,@ldaplib\@,$(ldaplib),g' \
-@BUNDLE_TRUE@	-e 's,@ldaplib_defs\@,$(ldaplib_defs),g'
+@BUNDLE_TRUE@	-e 's,@ldaplib_defs\@,$(ldaplib_defs),g' \
+@BUNDLE_TRUE@	-e 's,@systemdsystemunitdir\@,$(systemdsystemunitdir),g' \
+@BUNDLE_TRUE@	-e 's,@systemdsystemconfdir\@,$(systemdsystemconfdir),g' \
+@BUNDLE_TRUE@	-e 's,@systemdgroupname\@,$(systemdgroupname),g'
 
 all: $(BUILT_SOURCES) config.h
 	$(MAKE) $(AM_MAKEFLAGS) all-am
@@ -10062,6 +10081,26 @@ uninstall-schemaDATA:
 	test -n "$$files" || exit 0; \
 	echo " ( cd '$(DESTDIR)$(schemadir)' && rm -f" $$files ")"; \
 	cd "$(DESTDIR)$(schemadir)" && rm -f $$files
+install-systemdsystemunitDATA: $(systemdsystemunit_DATA)
+	@$(NORMAL_INSTALL)
+	test -z "$(systemdsystemunitdir)" || $(MKDIR_P) "$(DESTDIR)$(systemdsystemunitdir)"
+	@list='$(systemdsystemunit_DATA)'; test -n "$(systemdsystemunitdir)" || list=; \
+	for p in $$list; do \
+	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+	  echo "$$d$$p"; \
+	done | $(am__base_list) | \
+	while read files; do \
+	  echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(systemdsystemunitdir)'"; \
+	  $(INSTALL_DATA) $$files "$(DESTDIR)$(systemdsystemunitdir)" || exit $$?; \
+	done
+
+uninstall-systemdsystemunitDATA:
+	@$(NORMAL_UNINSTALL)
+	@list='$(systemdsystemunit_DATA)'; test -n "$(systemdsystemunitdir)" || list=; \
+	files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+	test -n "$$files" || exit 0; \
+	echo " ( cd '$(DESTDIR)$(systemdsystemunitdir)' && rm -f" $$files ")"; \
+	cd "$(DESTDIR)$(systemdsystemunitdir)" && rm -f $$files
 install-updateDATA: $(update_DATA)
 	@$(NORMAL_INSTALL)
 	test -z "$(updatedir)" || $(MKDIR_P) "$(DESTDIR)$(updatedir)"
@@ -10320,7 +10359,7 @@ check: $(BUILT_SOURCES)
 all-am: Makefile $(LIBRARIES) $(LTLIBRARIES) $(PROGRAMS) $(SCRIPTS) \
 		$(MANS) $(DATA) $(HEADERS) config.h
 installdirs:
-	for dir in "$(DESTDIR)$(serverdir)" "$(DESTDIR)$(serverplugindir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(initdir)" "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(taskdir)" "$(DESTDIR)$(updatedir)" "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(man8dir)" "$(DESTDIR)$(configdir)" "$(DESTDIR)$(infdir)" "$(DESTDIR)$(initconfigdir)" "$(DESTDIR)$(mibdir)" "$(DESTDIR)$(propertydir)" "$(DESTDIR)$(perldir)" "$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(propertydir)" "$(DESTDIR)$(sampledatadir)" "$(DESTDIR)$(schemadir)" "$(DESTDIR)$(updatedir)" "$(DESTDIR)$(serverincdir)"; do \
+	for dir in "$(DESTDIR)$(serverdir)" "$(DESTDIR)$(serverplugindir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(initdir)" "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(taskdir)" "$(DESTDIR)$(updatedir)" "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(man8dir)" "$(DESTDIR)$(configdir)" "$(DESTDIR)$(infdir)" "$(DESTDIR)$(initconfigdir)" "$(DESTDIR)$(mibdir)" "$(DESTDIR)$(propertydir)" "$(DESTDIR)$(perldir)" "$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(propertydir)" "$(DESTDIR)$(sampledatadir)" "$(DESTDIR)$(schemadir)" "$(DESTDIR)$(systemdsystemunitdir)" "$(DESTDIR)$(updatedir)" "$(DESTDIR)$(serverincdir)"; do \
 	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
 	done
 install: $(BUILT_SOURCES)
@@ -10469,8 +10508,8 @@ install-data-am: install-configDATA install-infDATA \
 	install-pkgconfigDATA install-propertyDATA \
 	install-sampledataDATA install-schemaDATA \
 	install-serverLTLIBRARIES install-serverincHEADERS \
-	install-serverpluginLTLIBRARIES install-taskSCRIPTS \
-	install-updateDATA install-updateSCRIPTS
+	install-serverpluginLTLIBRARIES install-systemdsystemunitDATA \
+	install-taskSCRIPTS install-updateDATA install-updateSCRIPTS
 
 install-dvi: install-dvi-am
 
@@ -10527,7 +10566,8 @@ uninstall-am: uninstall-binPROGRAMS uninstall-binSCRIPTS \
 	uninstall-sampledataDATA uninstall-sbinPROGRAMS \
 	uninstall-sbinSCRIPTS uninstall-schemaDATA \
 	uninstall-serverLTLIBRARIES uninstall-serverincHEADERS \
-	uninstall-serverpluginLTLIBRARIES uninstall-taskSCRIPTS \
+	uninstall-serverpluginLTLIBRARIES \
+	uninstall-systemdsystemunitDATA uninstall-taskSCRIPTS \
 	uninstall-updateDATA uninstall-updateSCRIPTS
 
 uninstall-man: uninstall-man1 uninstall-man8
@@ -10555,8 +10595,9 @@ uninstall-man: uninstall-man1 uninstall-man8
 	install-sbinPROGRAMS install-sbinSCRIPTS install-schemaDATA \
 	install-serverLTLIBRARIES install-serverincHEADERS \
 	install-serverpluginLTLIBRARIES install-strip \
-	install-taskSCRIPTS install-updateDATA install-updateSCRIPTS \
-	installcheck installcheck-am installdirs maintainer-clean \
+	install-systemdsystemunitDATA install-taskSCRIPTS \
+	install-updateDATA install-updateSCRIPTS installcheck \
+	installcheck-am installdirs maintainer-clean \
 	maintainer-clean-generic mostlyclean mostlyclean-compile \
 	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
 	tags uninstall uninstall-am uninstall-binPROGRAMS \
@@ -10568,7 +10609,8 @@ uninstall-man: uninstall-man1 uninstall-man8
 	uninstall-sampledataDATA uninstall-sbinPROGRAMS \
 	uninstall-sbinSCRIPTS uninstall-schemaDATA \
 	uninstall-serverLTLIBRARIES uninstall-serverincHEADERS \
-	uninstall-serverpluginLTLIBRARIES uninstall-taskSCRIPTS \
+	uninstall-serverpluginLTLIBRARIES \
+	uninstall-systemdsystemunitDATA uninstall-taskSCRIPTS \
 	uninstall-updateDATA uninstall-updateSCRIPTS
 
 
@@ -10598,9 +10640,16 @@ ns-slapd.properties: makstrdb
 	if [ ! -d $(dir $@) ] ; then mkdir -p $(dir $@) ; fi
 	$(fixupcmd) $^ > $@
 
-%/$(PACKAGE_NAME): %/initconfig.in
+%/$(PACKAGE_NAME): %/base-initconfig.in
 	if [ ! -d $(dir $@) ] ; then mkdir -p $(dir $@) ; fi
-	$(fixupcmd) $^ > $@
+@SYSTEMD_TRUE@	$(fixupcmd) $^ | sed -e 's/@preamble@/# This file is in systemd EnvironmentFile format - see man systemd.exec/' > $@
+@SYSTEMD_FALSE@	$(fixupcmd) $^ | sed -n -e 's/@preamble@//' -e '/^#/{p;d}' -e '/^$$/{p;d}' -e 's/^\([^=]*\)\(=.*\)$$/\1\2 ; export \1/ ; p' > $@
+@SYSTEMD_FALSE@	$(fixupcmd) $(srcdir)/ldap/admin/src/initconfig.in >> $@
+
+%/template-initconfig: %/template-initconfig.in
+	if [ ! -d $(dir $@) ] ; then mkdir -p $(dir $@) ; fi
+@SYSTEMD_TRUE@	$(fixupcmd) $^ | sed -e 's/@preamble@/# This file is in systemd EnvironmentFile format - see man systemd.exec/' > $@
+@SYSTEMD_FALSE@	$(fixupcmd) $^ | sed -n -e 's/@preamble@//' -e '/^#/{p;d}' -e '/^$$/{p;d}' -e 's/^\([^=]*\)\(=.*\)$$/\1\2 ; export \1/ ; p' > $@
 
 %/$(PACKAGE_NAME).pc: %/dirsrv.pc.in
 	if [ ! -d $(dir $@) ] ; then mkdir -p $(dir $@) ; fi
@@ -10610,6 +10659,19 @@ ns-slapd.properties: makstrdb
 	if [ ! -d $(dir $@) ] ; then mkdir -p $(dir $@) ; fi
 	$(fixupcmd) $^ > $@
 
+# yes, that is an @ in the filename . . .
+%/$(PACKAGE_NAME)@.service: %/systemd.template.service.in
+	if [ ! -d $(dir $@) ] ; then mkdir -p $(dir $@) ; fi
+	$(fixupcmd) $^ > $@
+
+%/$(systemdgroupname): %/systemd.group.in
+	if [ ! -d $(dir $@) ] ; then mkdir -p $(dir $@) ; fi
+	$(fixupcmd) $^ > $@
+
+%/$(PACKAGE_NAME)-snmp.service: %/systemd-snmp.service.in
+	if [ ! -d $(dir $@) ] ; then mkdir -p $(dir $@) ; fi
+	$(fixupcmd) $^ > $@
+
 # if distdir is a git tag, use that for the git archive tag, else
 # just assume a developer build and use HEAD
 git-archive:

+ 158 - 2
aclocal.m4

@@ -13,12 +13,168 @@
 
 m4_ifndef([AC_AUTOCONF_VERSION],
   [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
-m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.66],,
-[m4_warning([this file was generated for autoconf 2.66.
+m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.63],,
+[m4_warning([this file was generated for autoconf 2.63.
 You have another version of autoconf.  It may work, but is not guaranteed to.
 If you have problems, you may need to regenerate the build system entirely.
 To do so, use the procedure documented by the package, typically `autoreconf'.])])
 
+# pkg.m4 - Macros to locate and utilise pkg-config.            -*- Autoconf -*-
+# 
+# Copyright © 2004 Scott James Remnant <[email protected]>.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# PKG_PROG_PKG_CONFIG([MIN-VERSION])
+# ----------------------------------
+AC_DEFUN([PKG_PROG_PKG_CONFIG],
+[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
+m4_pattern_allow([^PKG_CONFIG(_PATH)?$])
+AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl
+if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
+	AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
+fi
+if test -n "$PKG_CONFIG"; then
+	_pkg_min_version=m4_default([$1], [0.9.0])
+	AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
+	if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
+		AC_MSG_RESULT([yes])
+	else
+		AC_MSG_RESULT([no])
+		PKG_CONFIG=""
+	fi
+		
+fi[]dnl
+])# PKG_PROG_PKG_CONFIG
+
+# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+#
+# Check to see whether a particular set of modules exists.  Similar
+# to PKG_CHECK_MODULES(), but does not set variables or print errors.
+#
+#
+# Similar to PKG_CHECK_MODULES, make sure that the first instance of
+# this or PKG_CHECK_MODULES is called, or make sure to call
+# PKG_CHECK_EXISTS manually
+# --------------------------------------------------------------
+AC_DEFUN([PKG_CHECK_EXISTS],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+if test -n "$PKG_CONFIG" && \
+    AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
+  m4_ifval([$2], [$2], [:])
+m4_ifvaln([$3], [else
+  $3])dnl
+fi])
+
+
+# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
+# ---------------------------------------------
+m4_define([_PKG_CONFIG],
+[if test -n "$$1"; then
+    pkg_cv_[]$1="$$1"
+ elif test -n "$PKG_CONFIG"; then
+    PKG_CHECK_EXISTS([$3],
+                     [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`],
+		     [pkg_failed=yes])
+ else
+    pkg_failed=untried
+fi[]dnl
+])# _PKG_CONFIG
+
+# _PKG_SHORT_ERRORS_SUPPORTED
+# -----------------------------
+AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+        _pkg_short_errors_supported=yes
+else
+        _pkg_short_errors_supported=no
+fi[]dnl
+])# _PKG_SHORT_ERRORS_SUPPORTED
+
+
+# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
+# [ACTION-IF-NOT-FOUND])
+#
+#
+# Note that if there is a possibility the first call to
+# PKG_CHECK_MODULES might not happen, you should be sure to include an
+# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
+#
+#
+# --------------------------------------------------------------
+AC_DEFUN([PKG_CHECK_MODULES],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
+AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
+
+pkg_failed=no
+AC_MSG_CHECKING([for $1])
+
+_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
+_PKG_CONFIG([$1][_LIBS], [libs], [$2])
+
+m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
+and $1[]_LIBS to avoid the need to call pkg-config.
+See the pkg-config man page for more details.])
+
+if test $pkg_failed = yes; then
+        _PKG_SHORT_ERRORS_SUPPORTED
+        if test $_pkg_short_errors_supported = yes; then
+	        $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "$2" 2>&1`
+        else 
+	        $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors "$2" 2>&1`
+        fi
+	# Put the nasty error message in config.log where it belongs
+	echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
+
+	ifelse([$4], , [AC_MSG_ERROR(dnl
+[Package requirements ($2) were not met:
+
+$$1_PKG_ERRORS
+
+Consider adjusting the PKG_CONFIG_PATH environment variable if you
+installed software in a non-standard prefix.
+
+_PKG_TEXT
+])],
+		[AC_MSG_RESULT([no])
+                $4])
+elif test $pkg_failed = untried; then
+	ifelse([$4], , [AC_MSG_FAILURE(dnl
+[The pkg-config script could not be found or is too old.  Make sure it
+is in your PATH or set the PKG_CONFIG environment variable to the full
+path to pkg-config.
+
+_PKG_TEXT
+
+To get pkg-config, see <http://pkg-config.freedesktop.org/>.])],
+		[$4])
+else
+	$1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
+	$1[]_LIBS=$pkg_cv_[]$1[]_LIBS
+        AC_MSG_RESULT([yes])
+	ifelse([$3], , :, [$3])
+fi[]dnl
+])# PKG_CHECK_MODULES
+
 # Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation

+ 0 - 6
config.h.in

@@ -247,9 +247,6 @@
    */
 #undef HAVE_SYS_NDIR_H
 
-/* Define to 1 if you have the <sys/param.h> header file. */
-#undef HAVE_SYS_PARAM_H
-
 /* Define to 1 if you have the <sys/socket.h> header file. */
 #undef HAVE_SYS_SOCKET_H
 
@@ -366,9 +363,6 @@
 /* Define to the one symbol short name of this package. */
 #undef PACKAGE_TARNAME
 
-/* Define to the home page for this package. */
-#undef PACKAGE_URL
-
 /* Define to the version of this package. */
 #undef PACKAGE_VERSION
 

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 1646 - 2008
configure


+ 67 - 2
configure.ac

@@ -311,6 +311,68 @@ else
 fi
 AC_SUBST(with_tmpfiles_d)
 
+PKG_PROG_PKG_CONFIG
+if test -n "$PKG_CONFIG" ; then
+   default_systemdsystemunitdir=`$PKG_CONFIG --variable=systemdsystemunitdir systemd`
+   default_systemdsystemconfdir=`$PKG_CONFIG --variable=systemdsystemconfdir systemd`
+fi
+AC_MSG_CHECKING(for --with-systemdsystemunitdir)
+AC_ARG_WITH([systemdsystemunitdir],
+   AS_HELP_STRING([--with-systemdsystemunitdir=PATH],
+                  [Directory for systemd service files (default: $with_systemdsystemunitdir)])
+)
+if test "$with_systemdsystemunitdir" = yes ; then
+  if test -n "$default_systemdsystemunitdir" ; then
+    with_systemdsystemunitdir=$default_systemdsystemunitdir
+    AC_MSG_RESULT([$with_systemdsystemunitdir])
+  else
+    AC_MSG_ERROR([You must specify --with-systemdsystemconfdir=/full/path/to/systemd/system directory])
+  fi
+elif test "$with_systemdsystemunitdir" = no ; then
+  with_systemdsystemunitdir=
+else
+  AC_MSG_RESULT([$with_systemdsystemunitdir])
+fi
+AC_SUBST(with_systemdsystemunitdir)
+
+AC_MSG_CHECKING(for --with-systemdsystemconfdir)
+AC_ARG_WITH([systemdsystemconfdir],
+   AS_HELP_STRING([--with-systemdsystemconfdir=PATH],
+                  [Directory for systemd service files (default: $with_systemdsystemconfdir)])
+)
+if test "$with_systemdsystemconfdir" = yes ; then
+  if test -n "$default_systemdsystemconfdir" ; then
+    with_systemdsystemconfdir=$default_systemdsystemconfdir
+    AC_MSG_RESULT([$with_systemdsystemconfdir])
+  else
+    AC_MSG_ERROR([You must specify --with-systemdsystemconfdir=/full/path/to/systemd/system directory])
+  fi
+elif test "$with_systemdsystemconfdir" = no ; then
+  with_systemdsystemconfdir=
+else
+  AC_MSG_RESULT([$with_systemdsystemconfdir])
+fi
+AC_SUBST(with_systemdsystemconfdir)
+
+if test -n "$with_systemdsystemunitdir" -o -n "$with_systemdsystemconfdir" ; then
+   if test -z "$with_systemdgroupname" ; then
+      with_systemdgroupname=$PACKAGE_NAME.target
+   fi
+   AC_MSG_CHECKING(for --with-systemdgroupname)
+   AC_ARG_WITH([systemdgroupname],
+        AS_HELP_STRING([--with-systemdgroupname=NAME],
+                       [Name of group target for all instances (default: $with_systemdgroupname)])
+   )
+   if test "$with_systemdgroupname" = yes ; then
+      AC_MSG_ERROR([You must specify --with-systemdgroupname=name.of.group])
+   elif test "$with_systemdgroupname" = no ; then
+      AC_MSG_ERROR([You must specify --with-systemdgroupname=name.of.group])
+   else
+      AC_MSG_RESULT([$with_systemdgroupname])
+   fi
+   AC_SUBST(with_systemdgroupname)
+fi
+
 AC_SUBST(configdir)
 AC_SUBST(sampledatadir)
 AC_SUBST(propertydir)
@@ -354,6 +416,7 @@ AM_CONDITIONAL([WINNT], false)
 # Deal with platform dependent defines
 # initdir is the location for the SysV init scripts - very heavily platform
 # dependent and not specified in fhs or lsb
+# and not used if systemd is used
 initdir='$(sysconfdir)/rc.d'
 AC_MSG_CHECKING(for --with-initddir)
 AC_ARG_WITH(initddir,
@@ -501,6 +564,7 @@ esac
 if test -n "$with_initddir" ; then
    initdir="$with_initddir"
 fi
+# sysv init scripts not used when systemd is used
 AC_SUBST(initdir)
 AC_SUBST(perlexec)
 AC_SUBST(sttyexec)
@@ -518,8 +582,9 @@ if test -z "$initconfigdir" ; then
 fi
 AC_SUBST(initconfigdir)
 
-AM_CONDITIONAL(HPUX,test "$platform" = "hpux")
-AM_CONDITIONAL(SOLARIS,test "$platform" = "solaris")
+AM_CONDITIONAL([HPUX],[test "$platform" = "hpux"])
+AM_CONDITIONAL([SOLARIS],[test "$platform" = "solaris"])
+AM_CONDITIONAL([SYSTEMD],[test -n "$with_systemdsystemunitdir" -o -n "$with_systemdsystemconfdir"])
 
 # Check for library dependencies
 m4_include(m4/nspr.m4)

+ 44 - 0
ldap/admin/src/base-initconfig.in

@@ -0,0 +1,44 @@
+# This file is sourced by @package_name@ upon startup to set
+# the default environment for all directory server instances.
+# To set instance specific defaults, use the file in the same
+# directory called @package_name@-instance where "instance"
+# is the name of your directory server instance e.g.
+# @package_name@-localhost for the slapd-localhost instance.
+
+@preamble@
+
+# In order to make more file descriptors available
+# to the directory server, first make sure the system
+# hard limits are raised, then use ulimit - uncomment
+# out the following line and change the value to the
+# desired value
+# ulimit -n 8192
+# note - if using systemd, ulimit won't work -  you must edit
+# the systemd unit file for directory server to add the 
+# LimitNOFILE option - see man systemd.exec for more info
+
+# A per instance keytab does not make much sense for servers.
+# Kerberos clients use the machine FQDN to obtain a ticket like ldap/FQDN, there
+# is nothing that can make a client understand how to get a per-instance ticket.
+# Therefore by default a keytab should be considered a per server option.
+
+# Also this file is sourced for all instances, so again all
+# instances would ultimately get the same keytab.
+
+# Finally a keytab is normally named either krb5.keytab or <service>.keytab
+
+# In order to use SASL/GSSAPI (Kerberos) the directory
+# server needs to know where to find its keytab
+# file - uncomment the following line and set
+# the path and filename appropriately
+# if using systemd, omit the "; export VARNAME" at the end
+# KRB5_KTNAME=@instconfigdir@/myname.keytab ; export KRB5_KTNAME
+
+# how many seconds to wait for the startpid file to show
+# up before we assume there is a problem and fail to start
+# if using systemd, omit the "; export VARNAME" at the end
+#STARTPID_TIME=10 ; export STARTPID_TIME
+# how many seconds to wait for the pid file to show
+# up before we assume there is a problem and fail to start
+# if using systemd, omit the "; export VARNAME" at the end
+#PID_TIME=600 ; export PID_TIME

+ 0 - 37
ldap/admin/src/initconfig.in

@@ -1,33 +1,3 @@
-# This file is sourced by @package_name@ upon startup to set
-# the default environment for all directory server instances.
-# To set instance specific defaults, use the file in the same
-# directory called @package_name@-instance where "instance"
-# is the name of your directory server instance e.g.
-# @package_name@-localhost for the slapd-localhost instance.
-
-# In order to make more file descriptors available
-# to the directory server, first make sure the system
-# hard limits are raised, then use ulimit - uncomment
-# out the following line and change the value to the
-# desired value
-# ulimit -n 8192
-
-# A per instance keytab does not make much sense for servers.
-# Kerberos clients use the machine FQDN to obtain a ticket like ldap/FQDN, there
-# is nothing that can make a client understand how to get a per-instance ticket.
-# Therefore by default a keytab should be considered a per server option.
-
-# Also this file is sourced for all instances, so again all
-# instances would ultimately get the same keytab.
-
-# Finally a keytab is normally named either krb5.keytab or <service>.keytab
-
-# In order to use SASL/GSSAPI (Kerberos) the directory
-# server needs to know where to find its keytab
-# file - uncomment the following line and set
-# the path and filename appropriately
-# KRB5_KTNAME=@instconfigdir@/myname.keytab ; export KRB5_KTNAME
-
 # other environment settings can be added here too
 OS=`uname -s`
 # use the new mt slab memory allocator on Solaris
@@ -40,10 +10,3 @@ if [ "$OS" = "SunOS" -a -f /usr/lib/64/libumem.so ] ; then
     LD_PRELOAD_64=/usr/lib/64/libumem.so
     export LD_PRELOAD_64
 fi
-
-# how many seconds to wait for the startpid file to show
-# up before we assume there is a problem and fail to start
-#STARTPID_TIME=10 ; export STARTPID_TIME
-# how many seconds to wait for the pid file to show
-# up before we assume there is a problem and fail to start
-#PID_TIME=600 ; export PID_TIME

+ 102 - 32
ldap/admin/src/scripts/DSCreate.pm.in

@@ -64,15 +64,26 @@ use Mozilla::LDAP::LDIF;
 
 use Exporter;
 @ISA       = qw(Exporter);
-@EXPORT    = qw(createDSInstance removeDSInstance setDefaults createInstanceScripts makeDSDirs
-                makeOtherConfigFiles installSchema updateSelinuxPolicy updateTmpfilesDotD);
-@EXPORT_OK = qw(createDSInstance removeDSInstance setDefaults createInstanceScripts makeDSDirs
-                makeOtherConfigFiles installSchema updateSelinuxPolicy updateTmpfilesDotD);
+@EXPORT    = qw(createDSInstance removeDSInstance setDefaults createInstanceScripts
+                makeOtherConfigFiles installSchema updateSelinuxPolicy updateTmpfilesDotD
+                get_initconfigdir updateSystemD makeDSDirs);
+@EXPORT_OK = qw(createDSInstance removeDSInstance setDefaults createInstanceScripts
+                makeOtherConfigFiles installSchema updateSelinuxPolicy updateTmpfilesDotD
+                get_initconfigdir updateSystemD makeDSDirs);
 
 use strict;
 
 use SetupLog;
 
+sub get_initconfigdir {
+    # determine initconfig_dir
+    if (getLogin eq 'root') {
+        return "@initconfigdir@";
+    } else {
+        return "$ENV{HOME}/.@package_name@";
+    }
+}
+
 sub checkPort {
     my $inf = shift;
 
@@ -277,14 +288,7 @@ sub createInstanceScripts {
     my $mydevnull = (-f "/dev/null" ? " /dev/null " : " NUL ");
 
     # determine initconfig_dir
-    my $initconfig_dir = $inf->{slapd}->{initconfig_dir};
-    if (!$initconfig_dir) {
-        if (getLogin eq 'root') {
-            $initconfig_dir = "$inf->{General}->{prefix}@initconfigdir@";
-        } else {
-            $initconfig_dir = "$ENV{HOME}/.@package_name@";
-        }
-    }
+    my $initconfig_dir = $inf->{slapd}->{initconfig_dir} || get_initconfigdir();
 
     my %maptable = (
         "DS-ROOT" => $inf->{General}->{prefix},
@@ -495,15 +499,7 @@ sub makeOtherConfigFiles {
     }
 
     # determine initconfig_dir
-    my $initconfig_dir = $inf->{slapd}->{initconfig_dir};
-    if (!$initconfig_dir) {
-        if (getLogin eq 'root') {
-            $initconfig_dir = "$inf->{General}->{prefix}@initconfigdir@";
-        } else {
-            $initconfig_dir = "$ENV{HOME}/.@package_name@";
-            mkpath $initconfig_dir unless -d $initconfig_dir;
-        }
-    }
+    my $initconfig_dir = $inf->{slapd}->{initconfig_dir} || get_initconfigdir();
 
     # install instance specific initconfig script
     $src = "$inf->{General}->{prefix}@configdir@/template-initconfig";
@@ -680,6 +676,9 @@ sub startServer {
     # get error log
     my $errLog = "$inf->{slapd}->{log_dir}/errors";
     my $startcmd = "$inf->{slapd}->{inst_dir}/start-slapd";
+    if ("@systemdsystemunitdir@" and (getLogin() eq 'root')) {
+        $startcmd = "/bin/systemctl start @package_name@\@$inf->{slapd}->{ServerIdentifier}.service";
+    }
 
     # emulate tail -f
     # if the last line we see does not contain "slapd started", try again
@@ -1061,6 +1060,73 @@ sub updateTmpfilesDotD {
     return ();
 }
 
+sub updateSystemD {
+    my $inf = shift;
+    my $unitdir = "@systemdsystemunitdir@";
+    my $confdir = "@systemdsystemconfdir@/@[email protected]";
+
+    if (!$unitdir or !$confdir or ! -d $unitdir or ! -d $confdir) {
+        debug(3, "no systemd - skipping\n");
+        return ();
+    }
+
+    my @errs = ();
+    my $initconfigdir = $inf->{slapd}->{initconfigdir} || get_initconfigdir();
+    debug(1, "updating systemd files in $unitdir and $confdir for all directory server instances in $initconfigdir\n");
+    my $pkgname = "@package_name@";
+    my $changes = 0;
+    # installation should already have put down the files and
+    # directories - we just need to update the symlinks
+    my $servicefile = "$unitdir/$pkgname\@.service";
+    # first, look for new instances
+    for my $file (glob("$initconfigdir/$pkgname-*")) {
+        my $inst = $file;
+        $inst =~ s/^.*$pkgname-//;
+        my $servicelink = "$confdir/$pkgname\@$inst.service";
+        if (! -l $servicelink) {
+            if (!symlink($servicefile, $servicelink)) {
+                debug(1, "error updating link $servicelink to $servicefile - $!\n");
+                push @errs, [ 'error_linking_file', $servicefile, $servicelink, $! ];
+            } else {
+                debug(2, "updated link $servicelink to $servicefile\n");
+            }
+            $changes++;
+        }
+    }
+    # next, look for instances that have been removed
+    for my $file (glob("$confdir/$pkgname\@*.service")) {
+        my $inst = $file;
+        $inst =~ s/^.*$pkgname\@(.*?).service$/$1/;
+        if (! -f "$initconfigdir/$pkgname-$inst") {
+            if (!unlink($file)) {
+                debug(1, "error removing $file - $!\n");
+                push @errs, [ 'error_removing_path', $file, $! ];
+            } else {
+                debug(2, "removed systemd file $file for removed instance $inst\n");
+            }
+            $changes++;
+        }
+    }
+    if ($changes > 0) {
+        $? = 0;
+        my $cmd = '/bin/systemctl --system daemon-reload';
+        # run the reload command
+        my $output = `$cmd 2>&1`;
+        my $status = $?;
+        if ($status) {
+            debug(1, "Error: $cmd failed - output $output: $!\n");
+            push @errs, [ 'error_running_command', $cmd, $output, $! ];
+        } else {
+            debug(2, "$cmd succeeded\n");
+        }
+    } else {
+        debug(1, "No changes to $unitdir or $confdir\n");
+    }
+ 
+
+    return @errs;
+}
+
 sub createDSInstance {
     my $inf = shift;
     my @errs;
@@ -1103,6 +1169,10 @@ sub createDSInstance {
         return @errs;
     }
 
+    if (@errs = updateSystemD($inf)) {
+        return @errs;
+    }
+
     if (@errs = startServer($inf)) {
         return @errs;
     }
@@ -1143,7 +1213,7 @@ sub stopServer {
 sub removeDSInstance {
     my $inst = shift;
     my $force = shift;
-    my $initconfig_dir = shift;
+    my $initconfig_dir = shift || get_initconfigdir();
     my $baseconfigdir = $ENV{DS_CONFIG_DIR} || "@instconfigdir@";
     my $instname = "slapd-$inst";
     my $configdir;
@@ -1151,15 +1221,6 @@ sub removeDSInstance {
     my $product_name;
     my @errs;
 
-    # determine initconfig_dir
-    if (!$initconfig_dir) {
-        if (getLogin eq 'root') {
-            $initconfig_dir = "@initconfigdir@";
-        } else {
-            $initconfig_dir = "$ENV{HOME}/.@package_name@";
-        }
-    }
-
     my $initconfig = "$initconfig_dir/@package_name@-$inst";
 
     # Get the configdir, rundir and product_name from the instance initconfig script.
@@ -1171,10 +1232,16 @@ sub removeDSInstance {
     while($line = <INFILE>) {
         if ($line =~ /CONFIG_DIR=(.*) ; export CONFIG_DIR/) {
             $configdir = $1;
-        } elsif ($line =~ /RUN_DIR=(.*) ; export INST_DIR/) {
+        } elsif ($line =~ /CONFIG_DIR=(.*)$/) {
+            $configdir = $1;
+        } elsif ($line =~ /RUN_DIR=(.*) ; export RUN_DIR/) {
+            $rundir = $1;
+        } elsif ($line =~ /RUN_DIR=(.*)$/) {
             $rundir = $1;
         } elsif ($line =~ /PRODUCT_NAME=(.*) ; export PRODUCT_NAME/) {
             $product_name = $1;
+        } elsif ($line =~ /PRODUCT_NAME=(.*)$/) {
+            $product_name = $1;
         }
     }
     close(INFILE);
@@ -1305,6 +1372,9 @@ sub removeDSInstance {
         }
     }
 
+    # update systemd files
+    push @errs, updateSystemD();
+
     # if we got here, report success
     if (@errs) {
         debug(1, "Could not successfully remove $instname\n");

+ 7 - 0
ldap/admin/src/scripts/DSMigration.pm.in

@@ -1160,6 +1160,13 @@ sub migrateDS {
             goto cleanup;
         }
 
+	# do the systemd stuff
+        @errs = DSCreate::updateSystemD($inf);
+        if (@errs) {
+            $mig->msg(@errs);
+            goto cleanup;
+        }
+
         # finally, start the server
         if ($mig->{start_servers}) {
             $inf->{slapd}->{start_server} = 1;

+ 2 - 0
ldap/admin/src/scripts/DSUpdate.pm.in

@@ -416,6 +416,8 @@ sub updateDSInstance {
 
     push @errs, updateTmpfilesDotD($inf);
 
+    push @errs, updateSystemD($inf);
+
     return @errs;
 }
 

+ 2 - 0
ldap/admin/src/scripts/setup-ds.res.in

@@ -197,3 +197,5 @@ If you proceed with this hostname, you may encounter problems.\
 Do you want to proceed with hostname '%s'?
 error_import_check_log = Error: unable to import file '%s' for backend '%s' - %s.  Check the errors log for additional information\n
 error_could_not_parse_nsstate = Error: could not parse nsState from %s.  Value: %s\n
+error_linking_file = Error: could not link '%s' to '%s': %s
+error_running_command = Error: command '%s' failed - output [%s] error [%s]

+ 11 - 7
ldap/admin/src/template-initconfig.in

@@ -7,12 +7,16 @@
 # start-slapd scripts (as well as their associates stop
 # and restart scripts).  Do not edit them unless you know
 # what you are doing.
-SERVER_DIR={{SERVER-DIR}} ; export SERVER_DIR
-SERVERBIN_DIR={{SERVERBIN-DIR}} ; export SERVERBIN_DIR
-CONFIG_DIR={{CONFIG-DIR}} ; export CONFIG_DIR
-INST_DIR={{INST-DIR}} ; export INST_DIR
-RUN_DIR={{RUN-DIR}} ; export RUN_DIR
-DS_ROOT={{DS-ROOT}} ; export DS_ROOT
-PRODUCT_NAME={{PRODUCT-NAME}} ; export PRODUCT_NAME
+
+@preamble@
+
+SERVER_DIR={{SERVER-DIR}}
+SERVERBIN_DIR={{SERVERBIN-DIR}}
+CONFIG_DIR={{CONFIG-DIR}}
+INST_DIR={{INST-DIR}}
+RUN_DIR={{RUN-DIR}}
+DS_ROOT={{DS-ROOT}}
+PRODUCT_NAME={{PRODUCT-NAME}}
 
 # Put custom instance specific settings below here.
+# if using systemd, omit the "; export VARNAME" at the end

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 152 - 378
ltmain.sh


+ 16 - 0
wrappers/systemd-snmp.service.in

@@ -0,0 +1,16 @@
+# do not edit this file in /lib/systemd/system - instead do the following:
+# cp /lib/systemd/system/dirsrv-snmp.service /etc/systemd/system/
+# edit /etc/systemd/system/dirsrv-snmp.service
+# systemctl daemon-reload 
+# systemctl (re)start dirsrv-snmp.service
+[Unit]
+Description=@capbrand@ Directory Server SNMP Subagent.
+After=syslog.target network.target
+
+[Service]
+Type=forking
+PIDFile=@localstatedir@/run/ldap-agent.pid
+ExecStart=@sbindir@/ldap-agent @configdir@/ldap-agent.conf 
+
+[Install]
+WantedBy=multi-user.target

+ 6 - 0
wrappers/systemd.group.in

@@ -0,0 +1,6 @@
+[Unit]
+Description=@capbrand@ Directory Server
+After=syslog.target network.target
+
+[Install]
+WantedBy=multi-user.target

+ 26 - 0
wrappers/systemd.template.service.in

@@ -0,0 +1,26 @@
+# do not edit this file in /lib/systemd/system - instead, do the following:
+# cp /lib/systemd/system/dirsrv\@.service /etc/systemd/system/dirsrv\@.service
+# mkdir -p /etc/systemd/system/@[email protected]
+# edit /etc/systemd/system/dirsrv\@.service - uncomment the LimitNOFILE=8192 line
+# where %i is the name of the instance
+# you may already have a symlink in
+# /etc/systemd/system/@[email protected]/dirsrv@%i.service pointing to
+# /lib/systemd/system/dirsrv\@.service - you will have to change it to link
+# to /etc/systemd/system/dirsrv\@.service instead
+# ln -s /etc/systemd/system/dirsrv\@.service /etc/systemd/system/@[email protected]/dirsrv@%i.service
+# systemctl daemon-reload 
+# systemctl (re)start @systemdgroupname@
+[Unit]
+Description=@capbrand@ Directory Server %i.
+BindTo=@systemdgroupname@
+After=@systemdgroupname@
+
+[Service]
+Type=forking
+Environment=PIDDIR=@localstatedir@/run/@package_name@
+EnvironmentFile=@initconfigdir@/@package_name@
+EnvironmentFile=@initconfigdir@/@package_name@-%i
+ExecStart=@sbindir@/ns-slapd -D @instconfigdir@/slapd-%i -i ${PIDDIR}/slapd-%i.pid -w ${PIDDIR}/slapd-%i.startpid
+# uncomment this line to raise the file descriptor limit - but do not edit this
+# file in /lib/systemd/system - see above for instructions
+# LimitNOFILE=8192

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно