admserv/newinst/src/AdminServer.pm.in | 27 +++++++++++++++++++++++++++
admserv/newinst/src/remove-ds-admin.pl.in | 8 ++++++--
2 files changed, 33 insertions(+), 2 deletions(-)
New commits:
commit cd9d6f19a2a2273d55f6ed18b1b8b292fa760838
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Thu Dec 20 11:42:02 2012 -0800
Ticket #293 - remove-ds-admin.pl does not remove everything
Bug Description: While remove-ds.pl takes "-a" option to remove
all the directories and files generated by setup-ds.pl, the
corresponding remove-ds-admin.pl for the entire system including
the Admin Server does not support "-a" option.
Fix Description: This patch makes remove-ds-admin.pl support
"-a" option. Admin Server setup script setup-ds-admin.pl backs
up the original files admserv.conf, httpd.conf, nss.conf,
console.conf, cert8.db, key3.db and secmod.db in the bakup
directory. By passing "-a" to remove-ds-admin.pl, it removes
directory server instances belonging to the Admin Server and
restores the files backed up by setup-ds-admin.pl. If "-a" is
not passed, the above files remain in the config directory.
https://fedorahosted.org/389/ticket/293
diff --git a/admserv/newinst/src/AdminServer.pm.in
b/admserv/newinst/src/AdminServer.pm.in
index f2de530..d769522 100644
--- a/admserv/newinst/src/AdminServer.pm.in
+++ b/admserv/newinst/src/AdminServer.pm.in
@@ -412,6 +412,20 @@ sub updateHttpConfFiles {
print CONSOLECONF @contents;
close (CONSOLECONF);
}
+ my @savefiles = qw(admserv.conf httpd.conf nss.conf console.conf cert8.db key3.db
secmod.db);
+ if (! -d "$admConf->{configdir}/bakup") {
+ if (system ("mkdir -p $admConf->{configdir}/bakup")) {
+ debug(0, "Error backing up $admConf->{configdir}/console.conf failed:
$!");
+ }
+ }
+ # backup savefiles for "remove-ds-admin.pl -a"
+ foreach my $savefile (@savefiles) {
+ if (! -f "$admConf->{configdir}/bakup/$savefile") {
+ if (system ("cp -p $admConf->{configdir}/$savefile
$admConf->{configdir}/bakup")) {
+ debug(0, "Error backing up $admConf->{configdir}/$savefile
failed: $!");
+ }
+ }
+ }
return 1;
}
@@ -617,6 +631,7 @@ sub stopAdminServer {
sub removeAdminServer {
my $baseconfigdir = shift;
my $force = shift;
+ my $all = shift;
if (!stopAdminServer()) {
if ($force) {
debug(1, "Warning: Could not stop admin server - forcing
continue\n");
@@ -737,6 +752,18 @@ sub removeAdminServer {
}
}
closedir(CONFDIR);
+ if ($all) {
+ # restore backed up savefiles
+ foreach my $savefile (@savefiles) {
+ if (-f "$configdir/bakup/$savefile") {
+ if (system ("mv $configdir/bakup/$savefile $configdir")) {
+ debug(0, "Error Restoring $configdir/$savefile failed:
$!");
+ }
+ }
+ }
+ }
+ # Clean up the bakup dir
+ system ("rm -rf $configdir/bakup");
} else {
debug(1, "Error: could not read config files in $configdir: $!");
if (!$force) {
diff --git a/admserv/newinst/src/remove-ds-admin.pl.in
b/admserv/newinst/src/remove-ds-admin.pl.in
index 297d1c3..545dbf3 100644
--- a/admserv/newinst/src/remove-ds-admin.pl.in
+++ b/admserv/newinst/src/remove-ds-admin.pl.in
@@ -31,6 +31,7 @@ use AdminServer qw(removeAdminServer);
sub usage {
print(STDERR "Usage: $0 [-f] [-d -d ...]\n\n");
print(STDERR " Opts: -f - force removal\n");
+ print(STDERR " -a - remove all\n");
print(STDERR " -d - turn on debugging output\n");
print(STDERR " -y - actually do the removal\n");
print(STDERR "WARNING: This command is extremely destructive!\n");
@@ -45,12 +46,15 @@ my $res = new Resource("@propertydir(a)/setup-ds.res",
my $i = 0;
my $force = "";
+my $all = 0;
my $seeny;
# load args from the command line
while ($i <= $#ARGV) {
if ( "$ARGV[$i]" eq "-f" ) {
$force = 1;
+ } elsif ("$ARGV[$i]" eq "-a") {
+ $all = 1;
} elsif ("$ARGV[$i]" eq "-d") {
$DSUtil::debuglevel++;
} elsif ( "$ARGV[$i]" eq "-y" ) {
@@ -95,7 +99,7 @@ for my $inst (@instances) {
exit 1;
}
}
- @errs = removeDSInstance($inst, $force);
+ @errs = removeDSInstance($inst, $force, $all);
if (@errs) {
print STDERR "The following errors occurred during removal of
$inst:\n";
for (@errs) {
@@ -109,7 +113,7 @@ for my $inst (@instances) {
}
# remove the admin server
-if (@errs = removeAdminServer($baseconfigdir, $force)) {
+if (@errs = removeAdminServer($baseconfigdir, $force, $all)) {
print STDERR "The following errors occurred during removal of the admin
server:\n";
for (@errs) {
print STDERR $res->getText($_);