Changeset 145


Ignore:
Timestamp:
Jun 2, 2010, 2:41:45 PM (14 years ago)
Author:
rock
Message:

修改 JAVA 判斷

File:
1 edited

Legend:

Unmodified
Added
Removed
  • nutchez-0.2/src/test/client_install_func.sh

    r144 r145  
    7272echo -e "\nNutchEz need Sun Java JDK 1.6.x or above version"
    7373
     74javaPath="/usr"
    7475yesno="no"
    75 while [ "$yesno" != "yes" ]
    76 do
    77     read -p "Plz input Sun Java home path (ex. '/usr/lib/jvm/java-6-sun-1.6.0.12' or using default '/usr' ): " javaPath
    78     read -p "Your java is ${javaPath}/bin/java. Is it correct (yes/no): " yesno
    79 done
    80 
    81 test -z JavaPath && $javaPath="/usr"
    82 
    83 if [ -e $javaPath/bin/java ]; then
    84     JAVA_org=$($javaPath/bin/java -version 2>&1 | grep "Java(TM)")
    85     JAVA_version=$($javaPath/bin/java -version 2>&1 | grep "java version" | \
    86     awk '{print $3}' | cut -d "." -f1-2 | cut -d "\"" -f2)
    87 
    88     if [ "$JAVA_org" == "" ]; then
    89         echo "Java is not Sun version, plz install sun Java 1.6.X"
    90         exit   
    91     fi
     76choice="3"
     77
     78    if [ -e $javaPath/bin/java ]; then
     79      JAVA_org=$($javaPath/bin/java -version 2>&1 | grep "Java(TM)")
     80      JAVA_version=$($javaPath/bin/java -version 2>&1 | grep "java version" | \
     81      awk '{print $3}' | cut -d "." -f1-2 | cut -d "\"" -f2)
    9282   
    93     large16=$(echo "$JAVA_version >= 1.6" | bc)
    94     if [ "${large16}" == 0 ]; then
    95         echo "Java version is too old (it need 1.6.X above)"
    96         exit
    97     fi
    98    
    99     echo "System has Sun Java 1.6 above version."
    100 else
    101     echo "Plz install Sun JAVA 1.6.X or above version"
    102     exit
    103 fi
     83        if [ "$JAVA_org" == "" ]; then
     84            echo "Java is not Sun version, plz install sun Java 1.6.X"
     85            echo -e "\nPlz input your choice: "
     86            echo "(1)System don't have Sun Java (2)Sun Java is in other path (3)Exit"
     87            read -p "plz input (1/2/3): " choice
     88            case $choice  in
     89                "1")
     90                echo -e "Plz install Sun Java manually!"
     91                exit
     92                ;;
     93                "2")
     94                    read -p "Input Sun Java home path(ex. '/usr/lib/jvm/java-6-sun-1.6.0.12' or using default '/usr' ): " javaPath
     95                ;;
     96                "*")
     97                exit
     98                ;;
     99            esac
     100
     101            if [ $choice == "2" ]; then
     102                JAVA_org=$($javaPath/bin/java -version 2>&1 | grep "Java(TM)")
     103                JAVA_version=$($javaPath/bin/java -version 2>&1 | grep "java version" | \
     104                awk '{print $3}' | cut -d "." -f1-2 | cut -d "\"" -f2)
     105               
     106                if [ "$JAVA_org" == "" ]; then
     107                echo -e "It is not Sun Java! Plz install Sun Java manually!"
     108                exit
     109                fi
     110            fi
     111        fi 
     112
     113      large16=$(echo "$JAVA_version >= 1.6" | bc)
     114      if [ "${large16}" == 0 ]; then
     115          echo "Java version is too old (it need 1.6.X above)"
     116          exit
     117      fi 
     118     
     119      echo "System has Sun Java 1.6 above version."
     120  else
     121      echo "Plz install Sun JAVA 1.6.X or above version"
     122      exit
     123  fi
    104124
    105125unset JAVA_org
Note: See TracChangeset for help on using the changeset viewer.