36
36
# Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
37
# Copyright (C) 2012 Red Hat, Inc.
37
# Copyright (C) 2013 Red Hat, Inc.
38
38
# All rights reserved.
39
39
# END COPYRIGHT BLOCK
43
print(STDERR "Usage: $0 [-v] -D rootdn { -w password | -w - | -j filename } \n");
44
print(STDERR " [-b basedn | -r rid | -A]\n");
45
print(STDERR " Opts: -D rootdn - Directory Manager\n");
46
print(STDERR " : -w password - Directory Manager's password\n");
47
print(STDERR " : -w - - Prompt for Directory Manager's password\n");
48
print(STDERR " : -j filename - Read Directory Manager's password from file\n");
49
print(STDERR " : -b basedn - DN of the replica root you want to clean\n");
50
print(STDERR " : -r rid - The replica id that you want to clean\n");
51
print(STDERR " : -A - Abort an existing cleanallruv task(must use with -b and -r args\n");
52
print(STDERR " : -v - verbose\n");
63
$prefix = "{{DS-ROOT}}";
65
$ENV{'PATH'} = "$prefix@ldaptool_bindir@:$prefix/usr/bin:@ldaptool_bindir@:/usr/bin";
67
libpath_add("$prefix@nss_libdir@");
68
libpath_add("$prefix/usr/lib");
69
libpath_add("@nss_libdir@");
70
libpath_add("/usr/lib");
72
$ENV{'SHLIB_PATH'} = "$ENV{'LD_LIBRARY_PATH'}";
77
if ("$ARGV[$i]" eq "-b")
80
$i++; $basedn = $ARGV[$i];
82
elsif ("$ARGV[$i]" eq "-r")
85
$i++; $rid = $ARGV[$i];
87
elsif ("$ARGV[$i]" eq "-A")
92
elsif ("$ARGV[$i]" eq "-D")
95
$i++; $rootdn = $ARGV[$i];
97
elsif ("$ARGV[$i]" eq "-w")
99
# Directory Manager's password
100
$i++; $passwd = $ARGV[$i];
102
elsif ("$ARGV[$i]" eq "-j")
104
# Read Directory Manager's password from a file
105
$i++; $passwdfile = $ARGV[$i];
107
elsif ("$ARGV[$i]" eq "-v")
119
if ($passwdfile ne ""){
120
# Open file and get the password
121
unless (open (RPASS, $passwdfile)) {
122
die "Error, cannot open password file $passwdfile\n";
127
} elsif ($passwd eq "-"){
128
# Read the password from terminal
129
print "Bind Password: ";
130
# Disable console echo
131
system("@sttyexec@ -echo") if -t STDIN;
134
# Enable console echo
135
system("@sttyexec@ echo") if -t STDIN;
137
chop($passwd); # trim trailing newline
140
if ( $rootdn eq "" || $passwd eq "" || $basedn eq "" || $rid eq "")
152
# Use a timestamp as part of the task entry name
153
($s, $m, $h, $dy, $mn, $yr, $wdy, $ydy, $r) = localtime(time);
157
# Build the task entry to add
158
$taskname = "cleanallruv_${yr}_${mn}_${dy}_${h}_${m}_${s}";
159
$dn = "dn: cn=$taskname, cn=cleanallruv, cn=tasks, cn=config\n";
161
$taskname = "abort_cleanallruv_${yr}_${mn}_${dy}_${h}_${m}_${s}";
162
$dn = "dn: cn=$taskname, cn=abort cleanallruv, cn=tasks, cn=config\n";
164
$misc = "changetype: add\nobjectclass: top\nobjectclass: extensibleObject\n";
165
$cn = "cn: $taskname\n";
166
$basedn = "replica-base-dn: $basedn\n";
167
$rid = "replica-id: $rid\n";
170
$entry = "${dn}${misc}${cn}${basedn}${rid}";
171
open(FOO, "| ldapmodify @ldaptool_opts@ $vstr -h {{SERVER-NAME}} -p {{SERVER-PORT}} -D \"$rootdn\" -w \"$passwd\" -a" );
179
if ($ENV{'LD_LIBRARY_PATH'}) {
180
$ENV{'LD_LIBRARY_PATH'} = "$ENV{'LD_LIBRARY_PATH'}:$libpath";
42
# We lose args that are quoted when passing ARGV to a wrapper
43
while ($i <= $#ARGV) {
44
if($ARGV[$i] =~ /^-/){
45
$wrapperArgs[$i] = $ARGV[$i];
182
$ENV{'LD_LIBRARY_PATH'} = "$libpath";
47
$wrapperArgs[$i] = "\"$ARGV[$i]\"";
52
exec "{{SERVERBIN-DIR}}/cleanallruv.pl @wrapperArgs -Z {{SERV-ID}}"
b'\\ No newline at end of file'