summaryrefslogtreecommitdiffstats
path: root/base/java-tools/pki
blob: 07194c9ed08ba4bdd066629ab5808c5fd05f33a2 (plain)
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/usr/bin/perl
# --- BEGIN COPYRIGHT BLOCK ---
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
#
# This library 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
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA  02110-1301  USA
#
# Copyright (C) 2007 Red Hat, Inc.
# All rights reserved.
# --- END COPYRIGHT BLOCK ---

###############################################################################
##  (1) Specify variables used by this script.                               ##
###############################################################################

my $PRODUCT="pki";
my $libpath="";


###############################################################################
##  (2) Define helper functions.                                             ##
###############################################################################

sub invalid_architecture()
{
    print "\n";
    print "ERROR:  pki does not execute on this architecture\n";
    print "ERROR:  check to make sure pki-tools package is installed!\n";
    print "\n";
}


###############################################################################
##  (3) Set the LD_LIBRARY_PATH environment variable                         ##
##      (as well as the ${libpath} java property) to determine the           ##
##      search order this command uses to find shared libraries.             ##
###############################################################################

my $ARCHITECTURE=`uname -i`;
chop( $ARCHITECTURE );

if( $ARCHITECTURE eq "i386" ) {
    $libpath="/usr/lib";

    $ENV{LD_LIBRARY_PATH} = "/usr/lib/jss:"
                          . "/usr/lib:/lib";
} elsif($ARCHITECTURE eq "x86_64") {
    $libpath="/usr/lib64";

    $ENV{LD_LIBRARY_PATH} = "/usr/lib64/jss:"
                          . "/usr/lib64:/lib64:"
                          . "/usr/lib/jss:"
                          . "/usr/lib:/lib";
} else {
    invalid_architecture();
    exit(255);
}


###############################################################################
##  (4) Set the CP environment variable to determine the search              ##
##      order this command wrapper uses to find jar files.                   ##
###############################################################################

my $RESTEASY_LIB = `source /etc/pki/pki.conf && echo \$RESTEASY_LIB`;
chomp($RESTEASY_LIB);

$ENV{CLASSPATH} = "/usr/share/java/${PRODUCT}/pki-certsrv.jar:"
                . "/usr/share/java/${PRODUCT}/pki-nsutil.jar:"
                . "/usr/share/java/${PRODUCT}/pki-tools.jar:"
                . "/usr/share/java/apache-commons-cli.jar:"
                . "/usr/share/java/apache-commons-codec.jar:"
                . "/usr/share/java/apache-commons-lang.jar:"
                . "/usr/share/java/apache-commons-logging.jar:"
                . "/usr/share/java/commons-httpclient.jar:"
                . "/usr/share/java/httpcomponents/httpclient.jar:"
                . "/usr/share/java/httpcomponents/httpcore.jar:"
                . "/usr/share/java/jaxb-api.jar:"
                . "${RESTEASY_LIB}/jaxrs-api.jar:"
                . "${RESTEASY_LIB}/resteasy-atom-provider.jar:"
                . "${RESTEASY_LIB}/resteasy-jaxb-provider.jar:"
                . "${RESTEASY_LIB}/resteasy-jaxrs.jar:"
                . "/usr/share/java/servlet.jar:";

if( $ARCHITECTURE eq "x86_64" ) {
    $ENV{CLASSPATH} = $ENV{CLASSPATH}
                    . "/usr/lib64/java/jss4.jar:"
                    . "/usr/lib/java/jss4.jar:";
} else {
    $ENV{CLASSPATH} = $ENV{CLASSPATH}
                    . "/usr/lib/java/jss4.jar:";
}


###############################################################################
##  (5) Execute the java command specified by this java command wrapper      ##
##      based upon the preset LD_LIBRARY_PATH and CP environment variables.  ##
###############################################################################

my @args = ();
foreach (@ARGV) {
    push(@args, quotemeta($_));
}

system("java -cp $ENV{CLASSPATH} com.netscape.cmstools.cli.MainCLI @args");