|
|
@@ -39,6 +39,13 @@
|
|
|
# END COPYRIGHT BLOCK
|
|
|
#
|
|
|
|
|
|
+use Getopt::Std;
|
|
|
+
|
|
|
+$opt_D = "{{ROOT-DN}}";
|
|
|
+$opt_p = "{{SERVER-PORT}}";
|
|
|
+$opt_h = "{{SERVER-NAME}}";
|
|
|
+$opt_v = 0;
|
|
|
+
|
|
|
sub usage {
|
|
|
print(STDERR "Usage: $0 [-v] -D rootdn { -w password | -w - | -j filename } \n");
|
|
|
print(STDERR " -n instance [-t attributeName[:indextypes[:matchingrules]]]\n");
|
|
|
@@ -56,6 +63,8 @@ sub usage {
|
|
|
print(STDERR " Example: -t foo:eq,pres\n");
|
|
|
print(STDERR " : -T vlvAttributeName - vlvAttributeName: name of the vlv attribute to be indexed\n");
|
|
|
print(STDERR " : -v - verbose\n");
|
|
|
+
|
|
|
+ exit 1;
|
|
|
}
|
|
|
|
|
|
$instance = "";
|
|
|
@@ -77,51 +86,25 @@ libpath_add("/usr/lib");
|
|
|
|
|
|
$ENV{'SHLIB_PATH'} = "$ENV{'LD_LIBRARY_PATH'}";
|
|
|
|
|
|
-$i = 0;
|
|
|
-while ($i <= $#ARGV)
|
|
|
-{
|
|
|
- if ("$ARGV[$i]" eq "-n")
|
|
|
- {
|
|
|
- # instance
|
|
|
- $i++; $instance = $ARGV[$i];
|
|
|
- }
|
|
|
- elsif ("$ARGV[$i]" eq "-D")
|
|
|
- {
|
|
|
- # Directory Manager
|
|
|
- $i++; $rootdn = $ARGV[$i];
|
|
|
- }
|
|
|
- elsif ("$ARGV[$i]" eq "-w")
|
|
|
- {
|
|
|
- # Directory Manager's password
|
|
|
- $i++; $passwd = $ARGV[$i];
|
|
|
- }
|
|
|
- elsif ("$ARGV[$i]" eq "-j")
|
|
|
- {
|
|
|
- # Read Directory Manager's password from a file
|
|
|
- $i++; $passwdfile = $ARGV[$i];
|
|
|
- }
|
|
|
- elsif ("$ARGV[$i]" eq "-t")
|
|
|
- {
|
|
|
- # Attribute to index
|
|
|
- $i++; $attribute_arg = $ARGV[$i];
|
|
|
- }
|
|
|
- elsif ("$ARGV[$i]" eq "-T")
|
|
|
- {
|
|
|
- # Vlvattribute to index
|
|
|
- $i++; $vlvattribute_arg = $ARGV[$i];
|
|
|
- }
|
|
|
- elsif ("$ARGV[$i]" eq "-v")
|
|
|
- {
|
|
|
- # verbose
|
|
|
- $verbose = 1;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- &usage; exit(1);
|
|
|
- }
|
|
|
- $i++;
|
|
|
+usage() if (!getopts('n:D:w:T:t:j:v'));
|
|
|
+
|
|
|
+if ($opt_j ne ""){
|
|
|
+ die "Error, cannot open password file $opt_j\n" unless (open (RPASS, $opt_j));
|
|
|
+ $opt_w = <RPASS>;
|
|
|
+ chomp($opt_w);
|
|
|
+ close(RPASS);
|
|
|
}
|
|
|
|
|
|
+usage() if( $opt_w eq "" );
|
|
|
+usage() if( $#ARGV ge 0 );
|
|
|
+
|
|
|
+$instance = $opt_n;
|
|
|
+$rootdn = $opt_D;
|
|
|
+$passwd = $opt_w;
|
|
|
+$attribute_arg = $opt_t;
|
|
|
+$vlvattribute_arg = $opt_T;
|
|
|
+$verbose = $opt_v;
|
|
|
+
|
|
|
if ($passwdfile ne ""){
|
|
|
# Open file and get the password
|
|
|
unless (open (RPASS, $passwdfile)) {
|
|
|
@@ -132,21 +115,20 @@ if ($passwdfile ne ""){
|
|
|
close(RPASS);
|
|
|
} elsif ($passwd eq "-"){
|
|
|
# Read the password from terminal
|
|
|
- print "Bind Password: ";
|
|
|
- # Disable console echo
|
|
|
- system("@sttyexec@ -echo") if -t STDIN;
|
|
|
- # read the answer
|
|
|
- $passwd = <STDIN>;
|
|
|
- # Enable console echo
|
|
|
- system("@sttyexec@ echo") if -t STDIN;
|
|
|
- print "\n";
|
|
|
- chop($passwd); # trim trailing newline
|
|
|
+ print "Bind Password: ";
|
|
|
+ # Disable console echo
|
|
|
+ system("@sttyexec@ -echo") if -t STDIN;
|
|
|
+ # read the answer
|
|
|
+ $passwd = <STDIN>;
|
|
|
+ # Enable console echo
|
|
|
+ system("@sttyexec@ echo") if -t STDIN;
|
|
|
+ print "\n";
|
|
|
+ chop($passwd); # trim trailing newline
|
|
|
}
|
|
|
|
|
|
if ( $rootdn eq "" || $passwd eq "" )
|
|
|
{
|
|
|
&usage;
|
|
|
- exit(1);
|
|
|
}
|
|
|
|
|
|
$vstr = "";
|
|
|
@@ -162,7 +144,6 @@ $taskname = "db2index_${yr}_${mn}_${dy}_${h}_${m}_${s}";
|
|
|
if ( $instance eq "" )
|
|
|
{
|
|
|
&usage;
|
|
|
- exit(1);
|
|
|
}
|
|
|
|
|
|
# No attribute name has been specified: let's get them from the configuration
|