36
36
# Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
37
# Copyright (C) 2008 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 " [-d schemadir]\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 " : -d schemadir - Directory where schema files are located\n");
50
print(STDERR " : -v - verbose\n");
60
$prefix = "{{DS-ROOT}}";
62
$ENV{'PATH'} = "$prefix@ldaptool_bindir@:$prefix/usr/bin:@ldaptool_bindir@:/usr/bin";
64
libpath_add("$prefix@nss_libdir@");
65
libpath_add("$prefix/usr/lib");
66
libpath_add("@nss_libdir@");
67
libpath_add("/usr/lib");
69
$ENV{'SHLIB_PATH'} = "$ENV{'LD_LIBRARY_PATH'}";
74
if ("$ARGV[$i]" eq "-d")
77
$i++; $schemadir_arg = $ARGV[$i];
79
elsif ("$ARGV[$i]" eq "-D")
82
$i++; $rootdn = $ARGV[$i];
84
elsif ("$ARGV[$i]" eq "-w")
86
# Directory Manager's password
87
$i++; $passwd = $ARGV[$i];
89
elsif ("$ARGV[$i]" eq "-j")
91
# Read Directory Manager's password from a file
92
$i++; $passwdfile = $ARGV[$i];
94
elsif ("$ARGV[$i]" eq "-v")
106
if ($passwdfile ne ""){
107
# Open file and get the password
108
unless (open (RPASS, $passwdfile)) {
109
die "Error, cannot open password file $passwdfile\n";
114
} elsif ($passwd eq "-"){
115
# Read the password from terminal
116
print "Bind Password: ";
117
# Disable console echo
118
system("@sttyexec@ -echo") if -t STDIN;
121
# Enable console echo
122
system("@sttyexec@ echo") if -t STDIN;
124
chop($passwd); # trim trailing newline
127
if ( $rootdn eq "" || $passwd eq "" )
139
# Use a timestamp as part of the task entry name
140
($s, $m, $h, $dy, $mn, $yr, $wdy, $ydy, $r) = localtime(time);
142
$taskname = "schema_reload_${yr}_${mn}_${dy}_${h}_${m}_${s}";
144
# Build the task entry to add
145
$dn = "dn: cn=$taskname, cn=schema reload task, cn=tasks, cn=config\n";
146
$misc = "changetype: add\nobjectclass: top\nobjectclass: extensibleObject\n";
147
$cn = "cn: $taskname\n";
149
if ( $schemadir_arg ne "" )
151
$schemadir = "schemadir: $schemadir_arg\n";
154
$entry = "${dn}${misc}${cn}${basedn}${schemadir}";
155
open(FOO, "| ldapmodify @ldaptool_opts@ $vstr -h {{SERVER-NAME}} -p {{SERVER-PORT}} -D \"$rootdn\" -w \"$passwd\" -a" );
163
if ($ENV{'LD_LIBRARY_PATH'}) {
164
$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];
166
$ENV{'LD_LIBRARY_PATH'} = "$libpath";
47
$wrapperArgs[$i] = "\"$ARGV[$i]\"";
52
exec "{{SERVERBIN-DIR}}/schema-reload.pl @wrapperArgs -Z {{SERV-ID}}";
b'\\ No newline at end of file'