Ignore:
Timestamp:
2007-10-24T09:27:36+13:00 (17 years ago)
Author:
qq6
Message:

looking for the JRE home first then the java home

Location:
greenstone3/branches/3.03
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • greenstone3/branches/3.03/gs3-server.bat

    r13931 r14728  
    11@echo off
    22
    3 set SERVERLANG=en
     3echo Greenstone 3 Server
     4echo Copyright (C) 2006, New Zealand Digital Library Project, University Of Waikato
     5echo This software comes with ABSOLUTELY NO WARRANTY; for details see LICENSE.txt
     6echo This is free software, and you are welcome to redistribute it
    47
    5 :: -------- Run the Greenstone 3 Server --------
    6 
    7 :: This script must be run from within the directory in which it lives
    8 if exist gs3-server.bat goto start
    9     if "%SERVERLANG%" == "en" echo This script must be run from the directory in which it resides.
    10     if "%SERVERLANG%" == "es" echo Este gui¢n deber  ejecutarse desde el directorio en el que reside.
    11     if "%SERVERLANG%" == "fr" echo Ce script doit ˆtre ex‚cut‚ 
 partir du r‚pertoire dans lequel il se trouve.
    12     if "%SERVERLANG%" == "ru" echo â®â áªàš¯â €®«Š¥­ ¡ëâì ¢§ïâ š§ €šà¥ªâ®àšš, ¢ ª®â®à®© ®­ à á¯®«®Š¥­
    13     goto exit
    14 
    15 :start
    16 if "%OS%" == "Windows_NT" goto findGSDL
    17     :: Invoke a new command processor to ensure there's enough environment space
    18     if "%1" == "Second" goto findGSDL
    19         command /E:2048 /C %0 Second %1 %2 %3 %4 %5 %6 %7 %8 %9
    20         goto done
    21 
    22 :findGSDL
    23 echo.
    24 if "%SERVERLANG%" == "en" echo Greenstone3 Server
    25 if "%SERVERLANG%" == "en" echo Copyright (C) 2006, New Zealand Digital Library Project, University Of Waikato
    26 if "%SERVERLANG%" == "en" echo This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE.txt
    27 if "%SERVERLANG%" == "en" echo This is free software, and you are welcome to redistribute it
    28 
    29 echo.
    308::  ---- Determine GSDL3HOME ----
     9:: Some users may set the above line manually
    3110set GSDL3PATH=
    3211
    33 :: Some users may set the above line manually
    34  if not "%GSDL3PATH%" == "" goto prepGSDL
     12:: The default location is the current directory
     13 if "%GSDL3PATH%" == "" set GSDL3PATH=.
    3514
    36  :: The default location is the current directory
    37  set GSDL3PATH=.
     15:: Setup Greenstone, unless it has already been done
     16if "%GSDL3SRCHOME%" == "" call "%GSDL3PATH%\gs3-setup.bat" SetEnv > nul
    3817
    39  :: If it is set, use the GSDLHOME environment variable
    40   if "%GSDL3SRCHOME%" == "" goto prepGSDL
    41   set GSDL3PATH=%GSDL3SRCHOME%
    42 
    43 :prepGSDL
    44 :: Setup Greenstone, unless it has already been done
    45 if not "%GSDL3SRCHOME%" == "" goto doneGSDL
    46    call "%GSDL3PATH%\gs3-setup.bat" SetEnv > nul
    47 
    48 :doneGSDL
    49 :: GSDL3PATH is no longer needed, since GSDL3SRCHOME should now be set
    5018set GSDL3PATH=
    5119
    52 :findJava
    53 :: ---- Check Java exists ----
    54 set JAVAPATH=
     20"%RUNJAVA%" -cp "%CLASSPATH%" org.greenstone.server.Server "%GSDL3SRCHOME%"
    5521
    56 :: Some users may set the above line manually
    57 if not "%JAVAPATH%" == "" goto testJava
    5822
    59 :: If it is set, use the JAVA_HOME environment variable
    60  if not "%JAVA_HOME%" == "" goto javahome
    6123
    62 :: Check if Java is on the search path
    63  echo %PATH%| winutil\which.exe java.exe | winutil\setvar.exe JAVAPATH > setjava.bat
    64  call setjava.bat
    65  del setjava.bat
    66  if not "%JAVAPATH%" == "" goto testJava
    67 
    68     :: Still haven't found anything, so try looking in the registry (gulp!)
    69     type nul > jdk.reg
    70     regedit /E jdk.reg "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit"
    71     type jdk.reg > jdk.txt
    72     del jdk.reg
    73     type nul > jre.reg
    74     regedit /E jre.reg "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment"
    75     type jre.reg > jre.txt
    76     del jre.reg
    77 
    78     winutil\findjava.exe jdk.txt jre.txt | winutil\setvar.exe JAVAPATH > setjava.bat
    79     del jdk.txt
    80     del jre.txt
    81     call setjava.bat
    82     del setjava.bat
    83 
    84    :: If nothing was found in the registry, we're stuck
    85    if "%JAVAPATH%" == "" goto noJava
    86 
    87    set JAVAPATH=%JAVAPATH%\bin
    88    goto testJava
    89 
    90 :javahome
    91     set JAVAPATH=%JAVA_HOME%\bin
    92 
    93 :testJava
    94 :: Check that a Java executable has been found
    95   if "%SERVERLANG%" == "en" echo Checking Java: %JAVAPATH%
    96   if "%SERVERLANG%" == "es" echo Revisando Java: %JAVAPATH%
    97   if "%SERVERLANG%" == "fr" echo V‚rification de Java: %JAVAPATH%
    98   if "%SERVERLANG%" == "ru" echo à®¢¥àª  Java: %JAVAPATH%
    99   if exist "%JAVAPATH%\java.exe" goto checkServer
    100 
    101 :noJava
    102  echo.
    103     if "%SERVERLANG%" == "en" echo Failed to locate an appropriate version of Java. You must install a
    104     if "%SERVERLANG%" == "en" echo Java Runtime Environment (version 1.4 or greater) before running the
    105     if "%SERVERLANG%" == "en" echo Greenstone3 Server.
    106     goto exit
    107 
    108 :checkServer
    109 ::---- Check that the server program has been compiled ----
    110 if exist "server.jar" goto runServer
    111 if "%SERVERLANG%" == "en" echo "You need to compile the code before running the server"
    112 goto exit
    113 
    114 :runServer
    115 echo Running the Greenstone Server
    116 :: -Xms32M          To set minimum memory
    117 :: -Xmx32M          To set maximum memory
    118 :: -verbose:gc      To set garbage collection messages
    119 :: -Xincgc          For incremental garbage collection
    120 :: -Xprof           Function call profiling
    121 :: -Xloggc:<file>   Write garbage collection log
    122 
    123 "%JAVAPATH%\java" -cp "%CLASSPATH%" org.greenstone.server.Server "%GSDL3SRCHOME%"
    124 
    125 :exit
    126 
    127 :done
    128 :: ---- Clean up ----
    129 set JAVAPATH=
    13024
    13125 
  • greenstone3/branches/3.03/gs3-server.sh

    r13499 r14728  
    22serverlang=en
    33
    4 echo
    54echo "Greenstone 3 Server"
    65echo "Copyright (C) 2006, New Zealand Digital Library Project, University Of Waikato"
    76echo "This software comes with ABSOLUTELY NO WARRANTY; for details see LICENSE.txt"
    87echo "This is free software, and you are welcome to redistribute it"
    9 echo
    108
    119##  -------- Run the Greenstone 3 Server --------
     
    1412thisdir=`pwd`
    1513if [ ! -f "${thisdir}/gs3-server.sh" ]; then
    16     if [ "$serverlang" == "es" ]; then
    17         echo "Este guión deberá ejecutarse desde el directorio en el que reside."
    18     elif [ "$serverlang" == "fr" ]; then
    19     echo "Ce script doit être exécuté à partir du répertoire dans lequel il se trouve."
    20     elif [ "$serverlang" == "ru" ]; then
    21     echo "üÔÏÔ ÓËÒÉÐÔ ÄÏÌÖÅÎ ÂÙÔØ ×ÚÑÔ ÉÚ ÄÉÒÅËÔÏÒÉÉ, × ËÏÔÏÒÏÊ ÏÎ ÒÁÓÐÏÌÏÖÅÎ"
    22     else
    23     echo "This script must be run from the directory in which it resides."
    24     fi
     14    echo "This script must be run from the directory in which it resides."
    2515    exit 1
    2616fi
    27 
    2817
    2918##  ---- Determine GSDL3SRCHOME ----
     
    3120
    3221# Some users may set the above line manually
    33 if [ "x$gsdl3path" == "x" ]; then
    34     # Check the environment variable first
    35     if [ "x$GSDL3SRCHOME" != "x" ]; then
    36     gsdl3path=$GSDL3SRCHOME
    37     else
    38     gsdl3path=`pwd`
    39     fi
     22if [ -z "$gsdl3path" ]; then
     23   gsdl3path=`pwd` 
    4024fi
    4125
    42 # Setup Greenstone3, unless it has already been done
    43 if [ "x$GSDL3SRCHOME" == "x" ]; then
    44     pushd $gsdl3path > /dev/null
    45     source gs3-setup.sh
    46     popd > /dev/null
    47 fi
    48 
    49 ## ---- Check Java exists ----
    50 javapath=
    51 
    52 # Some users may set the above line manually
    53 if [ "x$javapath" = "x" ]; then
    54 
    55     # If it is set, use the JAVA_HOME environment variable
    56     if [ "x$JAVA_HOME" != "x" ]; then
    57         javapath="$JAVA_HOME/bin/java"
    58 
    59     # Check if Java is on the search path
    60     else
    61         javapath=`which java 2> /dev/null`
    62     fi
    63 fi
    64 
    65 # Check that a Java executable has been found
    66 if [ "$glilang" = "es" ]; then
    67     echo "Revisando Java: $javapath"
    68 elif [ "$glilang" = "fr" ]; then
    69     echo "V<E9>rification de Java: $javapath"
    70 elif [ "$glilang" = "ru" ]; then
    71     echo "<F0><D2><CF><D7><C5><D2><CB><C1> Java: $javapath"
    72 else
    73     echo "Checking Java: $javapath"
    74 fi
    75 if [ ! -x "$javapath" ]; then
    76     echo
    77     echo "Failed to locate an appropriate version of Java. You must installa"
    78     echo "Java Runtime Environment (version 1.4 or greater) before running the"
    79     echo "Greenstone Server."
    80 exit 1
    81 fi
    82 
    83 ## -- Check the version of Java is new enough (1.4.0 or higher) to run the Server -- do we need this?
    84 #`$javapath -classpath . CheckJavaVersion > /dev/null`
    85 #if [ $? -ne 2 ] ; then
    86 #   echo "The version of the Java Runtime Environment you have installed is too"
    87 #   echo "old to run the Greenstone Librarian Interface. Please install a new"
    88 #   echo "version of the JRE (version 1.4 or newer) and rerun this script."
    89 #exit 1
    90 #fi
    91 
    92 ## ---- Check that the server has been compiled ----
    93 if [ ! -f server.jar ]; then
    94   echo "You need to compile the server before running this script"
    95   exit 1
     26if [ -z "$GSDL3SRCHOME" ]; then
     27  # Setup Greenstone3, unless it has already been done
     28  pushd $gsdl3path > /dev/null
     29  source gs3-setup.sh
     30  popd > /dev/null
    9631fi
    9732
    9833
    99 # Other arguments you can provide to java
    100 # -Xms<number>M    To set minimum memory (by default 32MB)
    101 # -Xmx<number>M    To set maximum memory (by default the nearest 2^n to the total remaining physical memory)
    102 # -verbose:gc      To set garbage collection messages
    103 # -Xincgc          For incremental garbage collection (significantly slows performance)
    104 # -Xprof           Function call profiling
    105 # -Xloggc:<file>   Write garbage collection log
     34# JRE_HOME or JAVA_HOME must be set correctly to run this program
     35if [ -n "$RUNJAVA" ]; then
     36  "$RUNJAVA" -cp $CLASSPATH org.greenstone.server.Server $GSDL3SRCHOME
     37fi
    10638
    107 java -cp $CLASSPATH org.greenstone.server.Server $GSDL3SRCHOME
  • greenstone3/branches/3.03/gs3-setup.bat

    r13932 r14728  
    11@echo off
     2
     3::get user defined environment variable
     4set JRE_HOME=
     5set JAVA_HOME=
     6set CLASSPATH=
    27
    38if exist gs3-setup.bat goto start
     
    3338del setcp.bat
    3439
    35 echo CLASSPATH: %CLASSPATH%
     40goto findJREHOME
    3641
    37 ::cd %GSDL3HOME%
     42:: ---- Check JRE_HOME ----
     43:findJREHOME
     44if not "%JRE_HOME%" == "" goto testJREHOME
     45   goto findJREHOME2     
    3846
    39 :findJava
    40 :: ---- Check Java SDK exists ----
    41 set JAVAPATH=
     47::---- try JREHOME ----
     48:findJREHOME2
     49if "%JREHOME%" == "" goto findJAVAHOME 
     50   set JRE_HOME=%JREHOME%
     51   testJREHOME
    4252
    43 :: Some users may set the above line manually
    44 if not "%JAVAPATH%" == "" goto testJava
    45    
    46 :: If it is set, use the JAVA_HOME environment variable
    47     if not "%JAVA_HOME%" == "" goto javahome
     53::test JRE_HOME is set correctly
     54:testJREHOME
     55if exist "%JRE_HOME%\bin\java.exe" goto gotJREHOME
     56   echo JRE_HOME: "%JRE_HOME%" 
     57   echo Couldn't find "%JRE_HOME%\bin\java.exe"
     58   echo The JRE_HOME environment variable is not defined correctly
     59   echo This environment variable is needed to run this program
     60   goto pauseANdExit   
    4861
    49     :: Check if Java is on the search path
    50     echo %PATH%| winutil\which.exe java.exe | winutil\setvar.exe JAVAPATH > setjava.bat
    51     call setjava.bat
    52     del setjava.bat
    53     echo %JAVAPATH%
    54     if not "%JAVAPATH%" == "" goto testJava
    5562
    56     :: Still haven't found anything, so try looking in the registry (gulp!)
    57     type nul > jdk.reg
    58     regedit /E jdk.reg "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit"
    59     type jdk.reg > jdk.txt
    60     del jdk.reg
    61     type nul > jre.reg
    62     regedit /E jre.reg "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment"
    63     type jre.reg > jre.txt
    64     del jre.reg
     63::set the RUNJAVA and exit
     64:gotJREHOME
     65 set RUNJAVA=%JRE_HOME%\bin\java.exe
     66 set PATH=%JRE_HOME%\bin;%PATH%
     67 echo JRE_HOME: "%JRE_HOME%"
     68 echo Your environment has successfully been set up to run Greenstone3
     69 goto exit
    6570
    66     winutil\findjava.exe jdk.txt jre.txt | winutil\setvar.exe JAVAPATH > setjava.bat
    67     del jdk.txt
    68     del jre.txt
    69     call setjava.bat
    70     del setjava.bat
    7171
    72     :: If nothing was found in the registry, we're stuck
    73     if "%JAVAPATH%" == "" goto noJava
     72:: ---- check JAVA_HOME ----
     73:findJAVAHOME
     74if not "%JAVA_HOME%" == "" goto testJAVAHOME
     75   goto findJAVAHOME2
    7476
    75     set JAVAPATH=%JAVAPATH%\bin
    76     goto testJava
     77 
     78::---- check JAVAHOME ----
     79:findJAVAHOME2
     80if "%JAVAHOME%" == "" goto noJAVAHOME 
     81   set JAVA_HOME=%JAVAHOME%
     82   testJAVAHOME
    7783
    78 :javahome
    79     set JAVAPATH=%JAVA_HOME%\bin
    8084
    81 :testJava
    82 if exist "%JAVAPATH%\java.exe" goto  exit
     85:: test JAVA_HOME is set Correctly
     86:testJAVAHOME
     87if not exist "%JAVA_HOME%\bin\java.exe" goto wrongJAVAHOME
     88if not exist "%JAVA_HOME%\bin\javac.exe" goto wrongJAVAHOME2
     89goto gotJAVAHOME
     90
     91
     92:wrongJAVAHOME
     93echo JAVA_HOME: "%JAVA_HOME%"
     94echo Couldn't find "%JAVA_HOME%\bin\java.exe"
     95echo The JAVA_HOME environment variable is not defined correctly
     96echo This environment variable is needed to run this program
     97goto pauseANdExit 
     98
     99:wrongJAVAHOME2
     100echo JAVA_HOME: "%JAVA_HOME%"
     101echo Couldn't find "%JAVA_HOME%\bin\javac.exe"
     102echo The JAVA_HOME environment variable is not defined correctly
     103echo This environment variable is needed to run this program
     104echo NB: JAVA_HOME should point to a JDK not a JRE
     105goto pauseANdExit
     106
     107::set the RUNJAVA and exit
     108:gotJAVAHOME
     109 set RUNJAVA=%JAVA_HOME%\bin\java.exe
     110 set PATH=%JAVA_HOME%\bin;%PATH%
     111 echo JAVA_HOME: "%JAVA_HOME%"
     112 echo Your environment has successfully been set up to run Greenstone3
     113 goto exit
     114
     115::try find java on the search path
     116:noJAVAHOME
     117:: Check if Java is on the search path
     118 echo %PATH%| winutil\which.exe java.exe | winutil\setvar.exe JAVAPATH > setjava.bat
     119 call setjava.bat
     120 del setjava.bat
     121
     122if exist "%JAVAPATH%\bin\java.exe" goto gotJava
     123 :: Still haven't found anything, so try looking in the registry (gulp!)
     124  type nul > jdk.reg
     125  regedit /E jdk.reg "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit"
     126  type jdk.reg > jdk.txt
     127  del jdk.reg
     128  type nul > jre.reg
     129  regedit /E jre.reg "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment"
     130  type jre.reg > jre.txt
     131  del jre.reg
     132
     133  winutil\findjava.exe jdk.txt jre.txt | winutil\setvar.exe JAVAPATH > setjava.bat
     134  del jdk.txt
     135  del jre.txt
     136  call setjava.bat
     137  del setjava.bat
     138
     139  :: If nothing was found in the registry, we're stuck
     140  if "%JAVAPATH%" == "" goto noJava
     141    goto gotJava
     142
     143:gotJava
     144  set JRE_HOME=%JAVAPATH%
     145  goto testJREHOME
    83146
    84147
    85148:noJava
    86     echo.
    87     echo Failed to locate an appropriate version of Java. You must install a
    88     echo Java Development Kit (version 1.4 or greater) before running the
     149    echo Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
     150    echo At least one of these environment variable is needed to run Greenstone3 
     151    echo You must install a Java Run Environment (version 1.4 or greater)
     152    echo and set the JRE_HOME environment variable before running the
    89153    echo Greenstone 3 Digital Library Software.
    90154    pause
    91155    goto exit
    92156
     157:pauseAndExit
     158 pause
     159 goto exit
     160 
    93161:exit
    94162
  • greenstone3/branches/3.03/gs3-setup.sh

    r13824 r14728  
    11# if this file is executed, /bin/sh is used, as we don't start with #!
    22# this should work under ash, bash, zsh, ksh, sh style shells.
    3 
    43# make sure we are sourced, and not run
    54
    6 if test "$0" != "`echo $0 | sed s/gs3-setup\.sh//`" ; then
    7 # if $0 contains "gs3-setup.sh" we've been run... $0 is shellname if sourced.
    8 # One exception is zsh has an option to set it temporarily to the script name
    9   if test -z "$ZSH_NAME" ; then
    10   # we aren't using zsh
    11   gsdl_not_sourced=true
     5export RUNJAVA=
     6JRE_HOME=
     7JAVA_HOME=
     8CLASSPATH=$CLASSPATH
     9
     10function testSource(){
     11  if test "$0" != "`echo $0 | sed s/gs3-setup\.sh//`" ; then
     12  # if $0 contains "gs3-setup.sh" we've been run... $0 is shellname if sourced.
     13  # One exception is zsh has an option to set it temporarily to the script name
     14    if test -z "$ZSH_NAME" ; then
     15    # we aren't using zsh
     16     gsdl_not_sourced=true
     17   fi
    1218  fi
    13 fi
    1419
    15 if test -n "$gsdl_not_sourced" ; then
    16   echo "    Error: Make sure you source this script, not execute it. Eg:"
    17   echo "        $ source gs3-setup.sh"
    18   echo "    or"
    19   echo "        $ . ./gs3-setup.sh"
    20   echo "    not"
    21   echo "        $ ./gs3-setup.sh"
    22   unset gsdl_not_sourced
    23   exit 1
    24 fi
     20  if test -n "$gsdl_not_sourced" ; then
     21     echo " Error: Make sure you source this script, not execute it. Eg:"
     22     echo "     $ source gs3-setup.sh"
     23     echo " or"
     24     echo "     $ . ./gs3-setup.sh"
     25     echo " not"
     26     echo "     $ ./gs3-setup.sh"
     27     unset gsdl_not_sourced
     28     exit 1
     29  fi
    2530
    26 if test ! -f gs3-setup.sh ; then
    27   echo "You must source the script from within the Greenstone home directory"
    28   exit 1
    29 fi
     31  if test ! -f gs3-setup.sh ; then
     32    echo "You must source the script from within the Greenstone home directory"
     33    exit 1
     34  fi
     35}
    3036
    31 GSDL3SRCHOME=`pwd`
    32 GSDL3HOME=$GSDL3SRCHOME/web
    33 export GSDL3HOME
    34 export GSDL3SRCHOME
    35 GSDLOS=`uname -s | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
    36 # check for running bash under cygwin
    37 if test "`echo $GSDLOS | sed 's/cygwin//'`" != "$GSDLOS" ; then
    38     GSDLOS=windows
    39 fi
    40 export GSDLOS
     37function setGS3ENV(){
     38   GSDL3SRCHOME=`pwd`
     39   GSDL3HOME=$GSDL3SRCHOME/web
     40   export GSDL3HOME
     41   export GSDL3SRCHOME
     42   GSDLOS=`uname -s | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
     43    # check for running bash under cygwin
     44    if test "`echo $GSDLOS | sed 's/cygwin//'`" != "$GSDLOS" ; then
     45        GSDLOS=windows
     46    fi
     47    export GSDLOS
    4148
    42 #change this if external tomcat
    43 TOMCAT_HOME=$GSDL3SRCHOME/packages/tomcat
     49    #change this if external tomcat
     50    TOMCAT_HOME=$GSDL3SRCHOME/packages/tomcat
    4451
    45 PATH=$GSDL3SRCHOME/bin/script:$GSDL3SRCHOME/bin:$PATH
    46 export PATH
    47 MANPATH=$MANPATH:$GSDL3SRCHOME/doc/man
    48 export MANPATH
     52    PATH=$GSDL3SRCHOME/bin/script:$GSDL3SRCHOME/bin:$PATH
     53    export PATH
     54    MANPATH=$MANPATH:$GSDL3SRCHOME/doc/man
     55    export MANPATH
    4956
    50 CLASSPATH=$GSDL3HOME/WEB-INF/classes:$GSDL3SRCHOME/resources/java:$CLASSPATH
    51 for JARFILE in $GSDL3SRCHOME/*.jar; do
    52     CLASSPATH=$CLASSPATH:$JARFILE
    53 done
    54 for JARFILE in $GSDL3SRCHOME/lib/jni/*.jar; do
    55     CLASSPATH=$CLASSPATH:$JARFILE
    56 done
    57 for JARFILE in $GSDL3HOME/WEB-INF/lib/*.jar; do
    58     CLASSPATH=$CLASSPATH:$JARFILE
    59 done
    60 for JARFILE in $TOMCAT_HOME/common/endorsed/*.jar; do
    61     CLASSPATH=$CLASSPATH:$JARFILE
    62 done   
    63 for JARFILE in $GSDL3SRCHOME/build/*.jar; do
    64     CLASSPATH=$CLASSPATH:$JARFILE
    65 done
     57    CLASSPATH=$GSDL3HOME/WEB-INF/classes:$GSDL3SRCHOME/resources/java:$CLASSPATH
     58     for JARFILE in $GSDL3SRCHOME/*.jar; do
     59       CLASSPATH=$CLASSPATH:$JARFILE
     60     done
     61     for JARFILE in $GSDL3SRCHOME/lib/jni/*.jar; do
     62        CLASSPATH=$CLASSPATH:$JARFILE
     63     done
     64     for JARFILE in $GSDL3HOME/WEB-INF/lib/*.jar; do
     65        CLASSPATH=$CLASSPATH:$JARFILE
     66     done
     67     for JARFILE in $TOMCAT_HOME/common/endorsed/*.jar; do
     68        CLASSPATH=$CLASSPATH:$JARFILE
     69     done   
     70     for JARFILE in $GSDL3SRCHOME/build/*.jar; do
     71       CLASSPATH=$CLASSPATH:$JARFILE
     72     done
     73     export CLASSPATH
     74     LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GSDL3SRCHOME/lib/jni
     75     export LD_LIBRARY_PATH
     76      ## for mac
     77     DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$GSDL3SRCHOME/lib/jni
     78     export DYLD_LIBRARY_PATH
     79}
    6680
    67 export CLASSPATH
     81function setJAVAHOME(){
     82    # see if we can find java
     83    java="java"
     84    jfound=1
     85    jok=1
     86    # if JREHOME, JRE_HOME is set, we'll use it to determine where java lives
     87    if [ "$JRE_HOME" != "" ]; then
     88       java="$JRE_HOME/bin/java"
     89       export JRE_HOME=$JRE_HOME
     90    elif [ "$JREHOME" != "" ]; then
     91       java="$JREHOME/bin/java"
     92       export JRE_HOME=$JREHOME
     93     # JAVAHOME or JAVA_HOME is set we'll use it to determine where java lives, otherwise
     94     #  we just hope it's on the search path
     95     elif [ "$JAVA_HOME" != "" ] ; then
     96       java="$JAVA_HOME/bin/java"
     97       export JAVA_HOME=$JAVA_HOME
     98     elif [ "$JAVAHOME" != "" ] ; then
     99       java="$JAVAHOME/bin/java"
     100       export JAVA_HOME=$JAVAHOME
     101    else
     102        java=`which java 2> /dev/null`
     103        if [ ! -x "$java" ]; then
     104        echo "Failed to locate Java. You must install a java runtime environment"
     105        echo "(version 1.4 or greater) before installing Greenstone 3."
     106            pauseAndExit
     107        else
     108      export JRE_HOME=`echo $java | sed -n 's/[\\\/]bin[\\\/]java$//p'`
     109        fi
     110   fi
     111   checkJAVAHOME
     112}
    68113
    69 LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GSDL3SRCHOME/lib/jni
    70 export LD_LIBRARY_PATH
    71 ## for mac
    72 DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$GSDL3SRCHOME/lib/jni
    73 export DYLD_LIBRARY_PATH
     114function checkJAVAHOME(){
     115# Make sure prerequisite environment variables are set
     116  if [ -z "$JAVA_HOME" -a -z "$JRE_HOME" ]; then
     117    echo "Neither the JAVA_HOME nor the JRE_HOME environment variable is defined"
     118    echo "At least one of these environment variable is needed to run Greenstone3" 
     119    pauseAndExit
     120  else # check JRE_HOME
     121      if [ -n "$JRE_HOME" ]; then
     122         if [ ! -x "$JRE_HOME"/bin/java ]; then
     123        echo "JRE_HOME: $JRE_HOME"
     124        echo "Couldn't find $JRE_HOME/bin/java"
     125            echo "The JRE_HOME environment variable is not defined correctly"
     126            echo "This environment variable is needed to run this program"
     127        pauseAndExit
     128         else
     129       export RUNJAVA="$JRE_HOME"/bin/java
     130           checkVersion
     131         fi     
     132      else
     133          # check JAVA_HOME if JRE_HOME is not set   
     134          if [ -n "$JAVA_HOME" ]; then
     135              if [ ! -x "$JAVA_HOME"/bin/java -o ! -x "$JAVA_HOME"/bin/javac ]; then
     136        echo "JAVA_HOME: $JAVA_HOME" 
     137                echo "Couldn't find $JAVA_HOME/bin/java or $JAVA_HOME/bin/javac"
     138                echo "The JAVA_HOME environment variable is not defined correctly"
     139                echo "This environment variable is needed to run this program"
     140                echo "NB: JAVA_HOME should point to a JDK not a JRE"
     141        pauseAndExit
     142          else
     143               export RUNJAVA="$JAVA_HOME"/bin/java
     144               checkVersion
     145              fi
     146           fi
     147        fi
     148  fi
     149}
    74150
    75 
    76 # see if we can find java
    77 java="java"
    78 jfound=1
    79 jok=1
    80 # if JAVAHOME or JAVA_HOME is set we'll use it to determine where java lives, otherwise
    81 #  we just hope it's on the search path
    82 if [ "$JAVA_HOME" != "" ] ; then
    83     java="$JAVA_HOME/bin/java"
    84 elif [ "$JAVAHOME" != "" ] ; then
    85     java="$JAVAHOME/bin/java"
    86     export JAVA_HOME=$JAVAHOME
    87 else
    88     java=`which java 2> /dev/null`
    89     if [ ! -x "$java" ]; then
    90     echo "Failed to locate Java. You must install a java runtime environment"
    91     echo "(version 1.4 or greater) before installing Greenstone 3."
    92     jfound=0
    93     jok=0
    94     else
    95     export JAVA_HOME=`echo $java | sed -n 's/[\\\/]bin[\\\/]java$//p'`
    96     fi
    97 fi
     151function checkVersion(){
    98152if [ $jfound -eq 1 ]; then
    99     javaversion=`$java -version 2>&1 | sed -n 's/^java version \"\(.*\)\"/\1/p'`
     153    javaversion=`$RUNJAVA -version 2>&1 | sed -n 's/^java version \"\(.*\)\"/\1/p'`
    100154    jvmajor=`echo $javaversion | sed -n 's/^\([0-9]*\).*$/\1/p'`
    101155    jvminor=`echo $javaversion | sed -n 's/^[0-9]*\.\([0-9]*\).*$/\1/p'`
     
    113167    echo "old to run Greenstone 3. Please install a new version of the JRE (version"
    114168    echo "1.4 or newer) and rerun this installation."
     169    export RUNJAVA=
     170    pauseAndExit
    115171else
     172    if [ -n "$JRE_HOME" ]; then
     173     echo "JRE_HOME: $JRE_HOME"
     174     export PATH="$JRE_HOME"\bin:$PATH
     175    fi
     176    if [ -n "$JAVA_HOME" ]; then
     177     echo "JAVA_HOME: $JAVA_HOME"
     178     export PATH="$JAVA_HOME"\bin:$PATH
     179    fi
    116180    echo "Your environment has successfully been set up to run Greenstone3"
    117181fi
    118 
    119 #do we need to check for perl???
    120 # make sure perl is ok
    121 #perl=`which perl 2> /dev/null`
    122 # echo "perl: $perl"
    123 #if [ ! -x "$perl" ] ; then
    124 #    echo "Greenstone 3 requires perl in order to operate but this installation"
    125 #    echo "could not detect perl on your system. Please ensure that perl is installed"
    126 #    echo "and is on your search path then rerun this installation script."
    127 #    exit 1
    128 #fi
     182}
    129183
    130184
     185function pauseAndExit(){
     186 echo -n "Please press any key to continue... "
     187 read
     188}
     189
     190testSource
     191setGS3ENV
     192setJAVAHOME
    131193
    132194
Note: See TracChangeset for help on using the changeset viewer.