#! /bin/sh ########################################################################## # checkJ: simple script to checks Java & Jini/JavaSpaces installations # # Provides a few parameters, with only simple support (ie, getopt is # not used, and no -help exists): # # -v = be verbose when reporting results (if given, it MUST be param #1) # -h = check for JNI (Java Native Interface) header files # -jini = check for Jini/JavaSpaces installation # # Note that -h and -jini are mutually exclusive. # # When no command line switches are given the script simply checks for Java. # # Return codes: # 0 = everything fine (blah is in $PATH and is a new enough version) # 1 = blah found in $PATH, but is not (or may not be) new enough version # 2 = blah was not found in $PATH (FATAL) # ########################################################################## if [ "$1" = "-v" ] ; then Verbose=1 shift else Verbose=0 fi # Always check that Java is installed and available javaPath=`type java 2>&1 | awk '{print $NF}' | grep "/bin/java"` if [ "$javaPath" = "" ] ; then echo "ERROR: You do not have Java/JDK in your \$PATH. Aborting." exit 2 fi javaVers=`sh -c "java -version 2>&1" | head -1 | grep "\"1\.[2-9]"` if [ "$javaVers" = "" ] ; then echo "WARNING: Your Java/Jdk version needs to be >= 1.2.x" 1>&2 retval=1 else retval=0 fi if [ "$1" = "-h" ] ; then javaBin=`dirname \`type java 2>/dev/null | awk '{print $NF}' \` ` javaTop=`dirname $javaBin` jniPlatDep=`cd ${javaTop}/include ; /usr/bin/find . -name jni_md.h` JNIHeaders="-I${javaTop}/include -I${javaTop}/include/`dirname ${jniPlatDep}`" if [ "$JNIHeaders" != "" ] ; then echo "$JNIHeaders" fi exit $retval fi # syntax: checkJ -ji [ [] [] ... ] if [ "$1" = "-jini" ] ; then shift if [ $# -gt 0 ] ; then fileToCheck=$1 shift else fileToCheck=lib/jini-core.jar fi if [ $# -gt 0 ] ; then dirs="$@" else dirs="$HOME /usr/local /usr" fi jiniDir="" retval=2 for dir in $dirs ; do for jdir in $dir/jini* ; do if [ -f $jdir/$fileToCheck ] && [ "$jiniDir" = "" ] ; then jiniDir=$jdir retval=0 fi done done if [ "$jiniDir" = "" ] ; then echo "ERROR: I could not find a Jini installation. Aborting." else if [ $Verbose -eq 1 ] ; then echo "Jini Installation: $jiniDir" else echo "$jiniDir" fi fi exit $retval fi if [ $Verbose -eq 1 ] ; then echo "Java Installation: $javaPath" else echo "$javaPath" fi exit $retval