Browse Source

Trac Ticket #34 - remove-ds.pl does not remove everything

https://fedorahosted.org/389/ticket/34

Fix description: Introduce an option "--all | -a", with which
all the generated files and directories are removed.
Noriko Hosoi 14 years ago
parent
commit
c013442930
2 changed files with 12 additions and 5 deletions
  1. 8 3
      ldap/admin/src/scripts/DSCreate.pm.in
  2. 4 2
      ldap/admin/src/scripts/remove-ds.pl.in

+ 8 - 3
ldap/admin/src/scripts/DSCreate.pm.in

@@ -1224,6 +1224,7 @@ sub stopServer {
 sub removeDSInstance {
     my $inst = shift;
     my $force = shift;
+    my $all = shift;
     my $initconfig_dir = shift || get_initconfigdir();
     my $baseconfigdir = $ENV{DS_CONFIG_DIR} || "@instconfigdir@";
     my $instname = "slapd-$inst";
@@ -1314,8 +1315,8 @@ sub removeDSInstance {
         push @errs, remove_tree($dbentry, "nsslapd-db-logdirectory", $instname, 1);
     }
     if ($entry) {
-        push @errs, remove_tree($entry, "nsslapd-lockdir", $instname);
-        push @errs, remove_tree($entry, "nsslapd-tmpdir", $instname);
+        push @errs, remove_tree($entry, "nsslapd-lockdir", $instname, 0);
+        push @errs, remove_tree($entry, "nsslapd-tmpdir", $instname, 0);
         push @errs, remove_tree($entry, "nsslapd-bakdir", $instname, 1);
         push @errs, remove_tree($entry, "nsslapd-errorlog", $instname, 1);
     }
@@ -1335,7 +1336,11 @@ sub removeDSInstance {
         }
     }
     # Finally, config dir
-    push @errs, remove_tree($entry, "nsslapd-schemadir", $instname, 1, "\.db\$");
+    if ($all) {
+        push @errs, remove_tree($entry, "nsslapd-schemadir", $instname, 1);
+    } else {
+        push @errs, remove_tree($entry, "nsslapd-schemadir", $instname, 1, "\.db\$");
+    }
 
     # Remove the instance specific initconfig script
     if ( -f $initconfig ) {

+ 4 - 2
ldap/admin/src/scripts/remove-ds.pl.in

@@ -43,12 +43,14 @@ sub usage {
 my $force = "";
 my $instname = "";
 my $initconfig_dir = "";
+my $all = "";
 
 GetOptions('help|h|?' => sub { &usage; exit(1); },
            'debug|d+' => \$DSUtil::debuglevel,
            'instance|i=s' => \$instname,
            'initconfig_dir|c=s' => \$initconfig_dir,
-           'force|f' => \$force
+           'force|f' => \$force,
+           'all|a' => \$all
            );
 
 # Make sure the instance name option was provided.
@@ -63,7 +65,7 @@ unless ($inst) {
     exit 1;
 }
 
-my @errs = removeDSInstance($inst, $force, $initconfig_dir);
+my @errs = removeDSInstance($inst, $force, $all, $initconfig_dir);
 if (@errs) {
     print STDERR "The following errors occurred during removal:\n";
     for (@errs) {