#!@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 DSUtil; use Resource; use DSCreate qw(removeDSInstance); 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 $i = 0; my $force = ""; my $instname = ""; # load args from the command line while ($i <= $#ARGV) { if ( "$ARGV[$i]" eq "-f" ) { $force = 1; } elsif ("$ARGV[$i]" eq "-i") { $i++; $instname = $ARGV[$i]; } elsif ("$ARGV[$i]" eq "-d") { $DSUtil::debuglevel++; } else { &usage; exit(1); } $i++; } # 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); 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: