From 941a7e89074e2ed0e0401aa778ccf412dce14fc8 Mon Sep 17 00:00:00 2001 From: Rich Megginson Date: Fri, 9 Feb 2007 22:33:59 +0000 Subject: Resolves: bug 160235 Bug Description: Add support for /etc/init scripts Reviewed by: nkinder (Thanks!) Fix Description: Add the new initscript. The initscript is called $PACKAGE_NAME which by default is fedora-ds. This script is created from wrappers/initscript.in, sed'd by the fixupcmd in Makefile.am during make install. The way it works is this: service fedora-ds cmd will execute the cmd on all instances (found in /etc/fedora-ds by default). service fedora-ds cmd instance will execute cmd on only that instance. So if you have /etc/fedora-ds/slapd-foo /etc/fedora-ds/slapd-bar and you do service start fedora-ds it will start up both slapd-foo and slapd-bar. If you do service start fedora-ds bar it will start up only slapd-bar. If you do service start fedora-ds biff you will get an error message. The initdir is platform specific (e.g. /etc/rc.d/init.d on linux, /etc/init.d on Solaris) so the definition was added to the platform dependent section of configure.ac. The init script is explicitly branded, including the filename. I needed to add support to the autotool files so that we could change the name of the file. Since package_name is defined when you use the AC_INIT macro in configure.ac, we don't need to define it elsewhere (e.g. #define BRAND_DS). So I added the branding and other information to the autotool files, and changed create_instance to use package_name instead of brand_ds to be consistent. Having the package_name defined in much fewer places should make it much easier to change in the future if necessary. I also fixed a compiler warning in ldaprot.h. Platforms tested: RHEL4, FC6 Flag Day: no Doc impact: Yes. We need to document how to use the initscript, and how to enable startup on boot - chkconfig fedora-ds on --- ldap/admin/src/create_instance.c | 56 ++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'ldap/admin/src/create_instance.c') diff --git a/ldap/admin/src/create_instance.c b/ldap/admin/src/create_instance.c index dc2a599e..8da5696b 100644 --- a/ldap/admin/src/create_instance.c +++ b/ldap/admin/src/create_instance.c @@ -709,7 +709,7 @@ char *gen_script_auto(char *s_root, char *cs_path, } PR_snprintf(ofn, sizeof(ofn), "%s%c%s%cscript-templates%ctemplate-%s", - cf->datadir, FILE_PATHSEP, cf->brand_ds, + cf->datadir, FILE_PATHSEP, cf->package_name, FILE_PATHSEP, FILE_PATHSEP, name); PR_snprintf(fn, sizeof(fn), "%s%c%s", cs_path, FILE_PATHSEP, name); create_instance_mkdir(cs_path, NEWDIR_MODE); @@ -724,7 +724,7 @@ char *gen_script_auto(char *s_root, char *cs_path, table[0][0] = "DS-ROOT"; table[0][1] = cf->prefix; table[1][0] = "DS-BRAND"; - table[1][1] = cf->brand_ds; + table[1][1] = cf->package_name; table[2][0] = "SEP"; table[2][1] = FILE_PATHSEPP; table[3][0] = "SERVER-NAME"; @@ -3419,13 +3419,13 @@ char *ds_gen_confs(char *sroot, server_config_s *cf, char *cs_path) /* install certmap.conf at */ PR_snprintf(src, sizeof(src), "%s%c%s%c/config/certmap.conf", - cf->sysconfdir, FILE_PATHSEP, cf->brand_ds, FILE_PATHSEP); + cf->sysconfdir, FILE_PATHSEP, cf->package_name, FILE_PATHSEP); PR_snprintf(dest, sizeof(dest), "%s/certmap.conf", cf->config_dir); create_instance_copy(src, dest, 0600, 0 ); /* generate /slapd-collations.conf */ PR_snprintf(src, sizeof(src), "%s%c%s%c/config/%s-collations.conf", - cf->sysconfdir, FILE_PATHSEP, cf->brand_ds, + cf->sysconfdir, FILE_PATHSEP, cf->package_name, FILE_PATHSEP, PRODUCT_NAME); PR_snprintf(dest, sizeof(dest), "%s%c%s-collations.conf", cf->config_dir, FILE_PATHSEP, PRODUCT_NAME); @@ -3448,16 +3448,16 @@ char *ds_gen_confs(char *sroot, server_config_s *cf, char *cs_path) fclose(f); /* - * /BRAND_DS/schema to schema_dir + * /PACKAGE_NAME/schema to schema_dir */ PR_snprintf(src, sizeof(src), "%s%c%s%cschema", - cf->sysconfdir, FILE_PATHSEP, cf->brand_ds, FILE_PATHSEP); + cf->sysconfdir, FILE_PATHSEP, cf->package_name, FILE_PATHSEP); if (NULL != (t = ds_copy_group_files_using_mode_owner(src, cf->schema_dir, 0, NEWFILE_MODE, pw))) return t; #if defined (BUILD_PRESENCE) PR_snprintf(src, sizeof(src), "%s%c%s%c/config/presence", - cf->sysconfdir, FILE_PATHSEP, cf->brand_ds, FILE_PATHSEP); + cf->sysconfdir, FILE_PATHSEP, cf->package_name, FILE_PATHSEP); PR_snprintf(dest, sizeof(dest), "%s/presence", cf->config_dir); if (t = ds_copy_group_files(src, dest, 0)) return t; @@ -4234,7 +4234,7 @@ set_path_attribute(char *attr, char *defaultval, char *prefix) /* * FHS description * cf->prefix: %{_prefix} - * cf->sroot: %{_libdir}/BRAND_DS + * cf->sroot: %{_libdir}/PACKAGE_NAME * cf->localstatedir: %{_localstatedir} * cf->sysconfdir: %{_sysconfdir} * cf->bindir: %{_bindir} @@ -4242,16 +4242,16 @@ set_path_attribute(char *attr, char *defaultval, char *prefix) * cf->datadir: %{_datadir} * cf->docdir: %{_docdir} * cf->inst_dir: /slapd- - * cf->config_dir: /lib/BRAND_DS/slapd- - * cf->schema_dir: /lib/BRAND_DS/slapd-/schema - * cf->lock_dir: /lock/BRAND_DS/slapd- - * cf->log_dir: /log/BRAND_DS/slapd- - * cf->run_dir: /run/BRAND_DS (slapd-instance.pid slapd-instance.startpid files) - * cf->db_dir: /lib/BRAND_DS/slapd-/db - * cf->bak_dir: /lib/BRAND_DS/slapd-/bak - * cf->tmp_dir: /tmp/BRAND_DS/slapd- + * cf->config_dir: /lib/PACKAGE_NAME/slapd- + * cf->schema_dir: /lib/PACKAGE_NAME/slapd-/schema + * cf->lock_dir: /lock/PACKAGE_NAME/slapd- + * cf->log_dir: /log/PACKAGE_NAME/slapd- + * cf->run_dir: /run/PACKAGE_NAME (slapd-instance.pid slapd-instance.startpid files) + * cf->db_dir: /lib/PACKAGE_NAME/slapd-/db + * cf->bak_dir: /lib/PACKAGE_NAME/slapd-/bak + * cf->tmp_dir: /tmp/PACKAGE_NAME/slapd- * cf->ldif_dir: //ldif - * cf->cert_dir: /BRAND_DS/slapd- + * cf->cert_dir: /PACKAGE_NAME/slapd- * cf->sasl_path: /sasl2 * cf->plugin_dir: /plugins * @@ -4274,7 +4274,7 @@ int parse_form(server_config_s *cf) int prefixlen = 0; LDAPURLDesc *desc = 0; - cf->brand_ds = BRAND_DS; + cf->package_name = PACKAGE_NAME; if (rm && qs && !strcmp(rm, "GET")) { ds_get_begin(qs); @@ -4301,7 +4301,7 @@ int parse_form(server_config_s *cf) } cf->sroot = PR_smprintf("%s%s%c%s", - prefix, LIBDIR, FILE_PATHSEP, cf->brand_ds); + prefix, LIBDIR, FILE_PATHSEP, cf->package_name); temp = ds_a_get_cgi_var("sasl_path", NULL, NULL); if (NULL != temp) { /* if sasl_path is given, we set it in the conf file regardless of @@ -4487,7 +4487,7 @@ int parse_form(server_config_s *cf) if (NULL == temp) { cf->config_dir = PR_smprintf("%s%c%s%c%s-%s", cf->sysconfdir, FILE_PATHSEP, - cf->brand_ds, FILE_PATHSEP, + cf->package_name, FILE_PATHSEP, PRODUCT_NAME, cf->servid); } else { cf->config_dir = PL_strdup(temp); @@ -4500,7 +4500,7 @@ int parse_form(server_config_s *cf) if (NULL == temp) { cf->schema_dir = PR_smprintf("%s%c%s%c%s-%s%cschema", cf->sysconfdir, FILE_PATHSEP, - cf->brand_ds, FILE_PATHSEP, + cf->package_name, FILE_PATHSEP, PRODUCT_NAME, cf->servid, FILE_PATHSEP); } else { cf->schema_dir = PL_strdup(temp); @@ -4510,7 +4510,7 @@ int parse_form(server_config_s *cf) if (NULL == temp) { cf->lock_dir = PR_smprintf("%s%clock%c%s%c%s-%s", cf->localstatedir, FILE_PATHSEP, FILE_PATHSEP, - cf->brand_ds, FILE_PATHSEP, + cf->package_name, FILE_PATHSEP, PRODUCT_NAME, cf->servid); } else { cf->lock_dir = PL_strdup(temp); @@ -4520,7 +4520,7 @@ int parse_form(server_config_s *cf) if (NULL == temp) { cf->log_dir = PR_smprintf("%s%clog%c%s%c%s-%s", cf->localstatedir, FILE_PATHSEP, FILE_PATHSEP, - cf->brand_ds, FILE_PATHSEP, + cf->package_name, FILE_PATHSEP, PRODUCT_NAME, cf->servid); } else { cf->log_dir = PL_strdup(temp); @@ -4530,7 +4530,7 @@ int parse_form(server_config_s *cf) if (NULL == temp) { cf->run_dir = PR_smprintf("%s%crun%c%s", cf->localstatedir, FILE_PATHSEP, FILE_PATHSEP, - cf->brand_ds); + cf->package_name); } else { cf->run_dir = PL_strdup(temp); } @@ -4541,7 +4541,7 @@ int parse_form(server_config_s *cf) if (NULL == temp) { cf->db_dir = PR_smprintf("%s%clib%c%s%c%s-%s%cdb", cf->localstatedir, FILE_PATHSEP, FILE_PATHSEP, - cf->brand_ds, FILE_PATHSEP, + cf->package_name, FILE_PATHSEP, PRODUCT_NAME, cf->servid, FILE_PATHSEP); } else { cf->db_dir = PL_strdup(temp); @@ -4551,7 +4551,7 @@ int parse_form(server_config_s *cf) if (NULL == temp) { cf->bak_dir = PR_smprintf("%s%clib%c%s%c%s-%s%cbak", cf->localstatedir, FILE_PATHSEP, FILE_PATHSEP, - cf->brand_ds, FILE_PATHSEP, + cf->package_name, FILE_PATHSEP, PRODUCT_NAME, cf->servid, FILE_PATHSEP); } else { cf->bak_dir = PL_strdup(temp); @@ -4562,7 +4562,7 @@ int parse_form(server_config_s *cf) temp = ds_a_get_cgi_var("ldif_dir", NULL, NULL); if (NULL == temp) { cf->ldif_dir = PR_smprintf("%s%c%s%cldif", - cf->datadir, FILE_PATHSEP, cf->brand_ds, FILE_PATHSEP); + cf->datadir, FILE_PATHSEP, cf->package_name, FILE_PATHSEP); } else { cf->ldif_dir = PL_strdup(temp); } @@ -4571,7 +4571,7 @@ int parse_form(server_config_s *cf) if (NULL == temp) { cf->tmp_dir = PR_smprintf("%s%ctmp%c%s%c%s-%s", cf->localstatedir, FILE_PATHSEP, FILE_PATHSEP, - cf->brand_ds, FILE_PATHSEP, + cf->package_name, FILE_PATHSEP, PRODUCT_NAME, cf->servid); } else { cf->tmp_dir = PL_strdup(temp); -- cgit