1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
#!@perlexec@
# BEGIN COPYRIGHT BLOCK
# This Program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; version 2 of the License.
#
# This Program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
# Place, Suite 330, Boston, MA 02111-1307 USA.
#
# Copyright (C) 2007 Red Hat, Inc.
# All rights reserved.
# END COPYRIGHT BLOCK
#
use lib qw(@perlpath@);
use strict;
use File::Basename;
use File::Path;
use Getopt::Long;
use DSUtil;
use Resource;
use DSCreate qw(removeDSInstance);
# process command line options
Getopt::Long::Configure(qw(bundling)); # bundling allows -ddddd
my $res = new Resource("@propertydir@/setup-ds.res");
sub usage {
print(STDERR "Usage: $0 [-f] [-d -d ... -d] -i instance\n\n");
print(STDERR " Opts: -f - force removal\n");
print(STDERR " -i instance - instance name to remove (e.g. - slapd-example)\n");
print(STDERR " -d - turn on debugging output\n");
}
my $force = "";
my $instname = "";
my $initconfig_dir = "";
GetOptions('help|h|?' => sub { &usage; exit(1); },
'debug|d+' => \$DSUtil::debuglevel,
'instance|i=s' => \$instname,
'initconfig_dir|c=s' => \$initconfig_dir,
'force|f' => \$force
);
# Make sure the instance name option was provided.
unless ($instname) {
&usage; exit(1);
}
# Make sure a full instance name was provided.
my ($slapd, $inst) = split(/-/, $instname, 2);
unless ($inst) {
print STDERR "Full instance name must be specified (e.g. - slapd-example)\n";
exit 1;
}
my @errs = removeDSInstance($inst, $force, $initconfig_dir);
if (@errs) {
print STDERR "The following errors occurred during removal:\n";
for (@errs) {
print STDERR $res->getText($_);
}
print STDERR "Error: could not remove directory server $inst\n";
exit 1;
}
# if we got here, report success
print "Instance $instname removed.\n";
exit 0;
# emacs settings
# Local Variables:
# mode:perl
# indent-tabs-mode: nil
# tab-width: 4
# End:
|