summaryrefslogtreecommitdiffstats
path: root/ldap/admin
diff options
context:
space:
mode:
authorNathan Kinder <nkinder@redhat.com>2010-04-01 11:12:02 -0700
committerNathan Kinder <nkinder@redhat.com>2010-04-01 12:08:36 -0700
commitf232bda45d7bc6216b091f38fa7ab4549ede6fde (patch)
tree9725835f48939ba25c39e3d1e4849ce30ff2420a /ldap/admin
parent6f4d92143892524fe55e1a80e8ca58fd708872ae (diff)
downloadds-f232bda45d7bc6216b091f38fa7ab4549ede6fde.tar.gz
ds-f232bda45d7bc6216b091f38fa7ab4549ede6fde.tar.xz
ds-f232bda45d7bc6216b091f38fa7ab4549ede6fde.zip
Allow instance name to be parsed from start-slapd
The admin server CGIs need to be able to easily parse the instance name from the start-slapd script. Recent format changes have caused the existing parsing to break, so this patch makes the parsing of the instance name easier. To deal with the change in start-slapd format for an upgraded instance, I have changed the setup code to regenerate all of the instance scripts during an upgrade instead of simply adding missing scripts. This is needed for any bug fix that modifies a script template to work for an upgraded instance. I also added code to write the instance sysconfig script during upgrade if it doesn't exist already. We don't want to overwrite this file if it already exists since it's designed for local changes to be made to it.
Diffstat (limited to 'ldap/admin')
-rw-r--r--ldap/admin/src/scripts/DSCreate.pm.in57
-rw-r--r--ldap/admin/src/scripts/DSUpdate.pm.in9
-rwxr-xr-xldap/admin/src/scripts/template-start-slapd.in3
3 files changed, 42 insertions, 27 deletions
diff --git a/ldap/admin/src/scripts/DSCreate.pm.in b/ldap/admin/src/scripts/DSCreate.pm.in
index 06b2d1fd..09b7cd11 100644
--- a/ldap/admin/src/scripts/DSCreate.pm.in
+++ b/ldap/admin/src/scripts/DSCreate.pm.in
@@ -64,8 +64,8 @@ use Mozilla::LDAP::LDIF;
use Exporter;
@ISA = qw(Exporter);
-@EXPORT = qw(createDSInstance removeDSInstance setDefaults createInstanceScripts installSchema);
-@EXPORT_OK = qw(createDSInstance removeDSInstance setDefaults createInstanceScripts installSchema);
+@EXPORT = qw(createDSInstance removeDSInstance setDefaults createInstanceScripts makeOtherConfigFiles installSchema);
+@EXPORT_OK = qw(createDSInstance removeDSInstance setDefaults createInstanceScripts makeOtherConfigFiles installSchema);
use strict;
@@ -436,6 +436,7 @@ sub createConfigFile {
sub makeOtherConfigFiles {
my $inf = shift;
+ my $skip = shift;
my @errs;
my %maptable = (
"DS-ROOT" => $inf->{General}->{prefix},
@@ -461,13 +462,18 @@ sub makeOtherConfigFiles {
$src = "$inf->{General}->{prefix}@configdir@/slapd-collations.conf";
$dest = "$inf->{slapd}->{config_dir}/slapd-collations.conf";
+
$! = 0; # clear errno
- copy($src, $dest);
- if ($!) {
- return ('error_copying_file', $src, $dest, $!);
- }
- if (@errs = changeOwnerMode($inf, 4, $dest)) {
- return @errs;
+
+ #in skip mode, skip files that already exist
+ unless ($skip and -f $dest) {
+ copy($src, $dest);
+ if ($!) {
+ return ('error_copying_file', $src, $dest, $!);
+ }
+ if (@errs = changeOwnerMode($inf, 4, $dest)) {
+ return @errs;
+ }
}
# determine initconfig_dir
@@ -487,22 +493,25 @@ sub makeOtherConfigFiles {
$! = 0; # clear errno
- if (!open(SRC, "< $src")) {
- return ("error_opening_scripttmpl", $src, $!);
- }
- if (!open(DEST, "> $dest")) {
- return ("error_opening_scripttmpl", $dest, $!);
- }
- my $contents; # slurp entire file into memory
- read SRC, $contents, int(-s $src);
- close(SRC);
- while (my ($key, $val) = each %maptable) {
- $contents =~ s/\{\{$key\}\}/$val/g;
- }
- print DEST $contents;
- close(DEST);
- if (@errs = changeOwnerMode($inf, 4, $dest)) {
- return @errs;
+ # in skip mode, skip files that already exist
+ unless ($skip and -f $dest) {
+ if (!open(SRC, "< $src")) {
+ return ("error_opening_scripttmpl", $src, $!);
+ }
+ if (!open(DEST, "> $dest")) {
+ return ("error_opening_scripttmpl", $dest, $!);
+ }
+ my $contents; # slurp entire file into memory
+ read SRC, $contents, int(-s $src);
+ close(SRC);
+ while (my ($key, $val) = each %maptable) {
+ $contents =~ s/\{\{$key\}\}/$val/g;
+ }
+ print DEST $contents;
+ close(DEST);
+ if (@errs = changeOwnerMode($inf, 4, $dest)) {
+ return @errs;
+ }
}
return ();
diff --git a/ldap/admin/src/scripts/DSUpdate.pm.in b/ldap/admin/src/scripts/DSUpdate.pm.in
index 3792afe2..3241a582 100644
--- a/ldap/admin/src/scripts/DSUpdate.pm.in
+++ b/ldap/admin/src/scripts/DSUpdate.pm.in
@@ -47,7 +47,7 @@ package DSUpdate;
use DSUtil;
use Inf;
use FileConn;
-use DSCreate qw(setDefaults createInstanceScripts);
+use DSCreate qw(setDefaults createInstanceScripts makeOtherConfigFiles);
use File::Basename qw(basename dirname);
@@ -315,7 +315,12 @@ sub updateDSInstance {
}
# upgrade instance scripts
- if (@errs = createInstanceScripts($inf, 1)) {
+ if (@errs = createInstanceScripts($inf, 0)) {
+ return @errs;
+ }
+
+ # add new or missing config files
+ if (@errs = makeOtherConfigFiles($inf, 1)) {
return @errs;
}
diff --git a/ldap/admin/src/scripts/template-start-slapd.in b/ldap/admin/src/scripts/template-start-slapd.in
index 444a37ff..0c9ac631 100755
--- a/ldap/admin/src/scripts/template-start-slapd.in
+++ b/ldap/admin/src/scripts/template-start-slapd.in
@@ -5,6 +5,7 @@
# 0: Server started successfully
# 1: Server could not be started
# 2: Server already running
+INSTANCE={{SERV-ID}}
-@sbindir@/start-dirsrv -d {{INITCONFIG-DIR}} {{SERV-ID}} "$@"
+@sbindir@/start-dirsrv -d {{INITCONFIG-DIR}} $INSTANCE "$@"
exit $?