summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRich Megginson <rmeggins@redhat.com>2010-03-01 07:26:48 -0700
committerRich Megginson <rmeggins@redhat.com>2010-03-02 09:12:12 -0700
commit3a9ca47eb2ae7f430ce07fd28a99fb7c22aa9207 (patch)
tree016cebf3e339e6b00be74ee6e34fec562b3aa106
parent142900b2757378bfbff34e3f390fcb1a292eea91 (diff)
downloadds-existingdir.tar.gz
ds-existingdir.tar.xz
ds-existingdir.zip
-rw-r--r--ldap/admin/src/scripts/DSCreate.pm.in18
-rw-r--r--ldap/admin/src/scripts/DSUtil.pm.in8
-rw-r--r--ldap/admin/src/scripts/setup-ds.res.in3
3 files changed, 27 insertions, 2 deletions
diff --git a/ldap/admin/src/scripts/DSCreate.pm.in b/ldap/admin/src/scripts/DSCreate.pm.in
index fb2a4d75..59a4568f 100644
--- a/ldap/admin/src/scripts/DSCreate.pm.in
+++ b/ldap/admin/src/scripts/DSCreate.pm.in
@@ -198,7 +198,6 @@ sub changeOwnerMode {
sub makeDSDirs {
my $inf = shift;
- my $verbose = ($DSUtil::debuglevel > 0);
my $mode = getMode($inf, 7);
my @errs;
@@ -207,6 +206,23 @@ sub makeDSDirs {
# more privileged user than the directory server, but
# still allows the admin server to manage directory
# server files/dirs without being root
+
+ # run through first time looking for pre-existing - if any already
+ # exist, report and exit
+ my $existing_dirs;
+ for my $kw (qw(inst_dir config_dir schema_dir log_dir lock_dir run_dir tmp_dir
+ cert_dir db_dir ldif_dir bak_dir)) {
+ my $dir = $inf->{slapd}->{$kw};
+ if (-d $dir) {
+ $existing_dirs .= `ls -ld $dir`;
+ }
+ }
+
+ if ($existing_dirs) {
+ return ('error_paths_already_exist', $existing_dirs);
+ }
+
+ # all clear - create them
for my $kw (qw(inst_dir config_dir schema_dir log_dir lock_dir run_dir tmp_dir
cert_dir db_dir ldif_dir bak_dir)) {
my $dir = $inf->{slapd}->{$kw};
diff --git a/ldap/admin/src/scripts/DSUtil.pm.in b/ldap/admin/src/scripts/DSUtil.pm.in
index 7e846d73..1b2fe633 100644
--- a/ldap/admin/src/scripts/DSUtil.pm.in
+++ b/ldap/admin/src/scripts/DSUtil.pm.in
@@ -834,6 +834,9 @@ sub makePaths {
my $gid = -1; # default to leave it alone
my $mode_string = "";
+ if (-d $path) {
+ debug(1, "Directory already exists ", `ls -ld $path`);
+ }
if ($group) {
$gid = getgrnam $group;
}
@@ -845,7 +848,10 @@ sub makePaths {
unshift @dirnames, $parent;
}
for my $dir (@dirnames) {
- next if (-d $dir);
+ if (-d $dir) {
+ debug(5, "Skipping creation of existing directory ", `ls -ld $dir`);
+ next;
+ }
$! = 0; # clear
mkdir $dir, $mode;
if ($!) {
diff --git a/ldap/admin/src/scripts/setup-ds.res.in b/ldap/admin/src/scripts/setup-ds.res.in
index af9080d4..fa0c20b4 100644
--- a/ldap/admin/src/scripts/setup-ds.res.in
+++ b/ldap/admin/src/scripts/setup-ds.res.in
@@ -183,3 +183,6 @@ error_online_update = Could not open a connection to the server at %s port %s as
Please make sure the server is up and running before using online mode,\
or use offline mode.\n\n
error_offline_update = Could not read the server config file '%s'. Error: %s\n\n
+error_paths_already_exist = Error: could not create the server instance.\
+The following paths already exist. Please save their contents, if necessary\
+and remove them, then re-run setup.\n%s\n