#!/bin/bash
# dos2unix *.sh
# Program:
# This program to install and config jdk .
# History:
# 2015/01/28 - add JRE_HOME
#---------------------------- custom variables ---------------------start
runuser=root
jdk=jdk-6u27-linux-x64.bin
#---------------------------- custom variables ---------------------end
#---------------------------- user check ---------------------start
if [ "`whoami`" != "$runuser" ]; then
echo "Please re-run ${this_file} as $runuser."
exit 1
fi
#---------------------------- user check ---------------------end
#---------------------------- function ---------------------start
choice ()
{
clear
echo "
Choose one of the following numbers:
[0]I quit
[1]install jdk
[2]config profile
[3]check java version and path
"
}
pause()
{
read -n1 -p "Press any key to continue..."
}
#---------------------------- function ---------------------end
#---------------------------- choice ---------------------start
clear
echo "
Choose one of the following numbers:
[0]I quit
[1]install jdk
[2]config profile
[3]check java version and path
"
while
echo "Input your choice: "
read choice
do
case $choice in
"0")
exit 0
;;
"1")
cp $jdk /usr/local
chmod u+x /usr/local/$jdk
cd /usr/local
/usr/local/$jdk
pause
choice
;;
"2")
cat >> /etc/profile << EOF
export JAVA_HOME=/usr/local/jdk1.6.0_27
export JRE_HOME=/usr/local/jdk1.6.0_27/jre
export PATH=\$JAVA_HOME/bin:\$PATH
EOF
source /etc/profile
pause
choice
;;
"3")
java -version
echo JAVA_HOME
pause
choice
;;
*)
choice
;;
esac
done
#---------------------------- choice ---------------------end