Created
February 2, 2013 18:11
-
-
Save angelo-v/4698640 to your computer and use it in GitHub Desktop.
Quick and dirty linux command line scripts to download and update java. It might not fit to your environment. Enhance and adapt it if you like, but use it on your own risk!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pass url of a java *.tar.gz file as the first and only parmeter | |
url=$1 | |
tmp=.temporary-java-download | |
function confirm () { | |
echo $1 | |
select yn in "Yes" "No"; do | |
case $yn in | |
Yes ) return 1; break;; | |
No ) return 0; exit;; | |
esac | |
done | |
} | |
mkdir $tmp | |
cd $tmp | |
confirm "Download Java from $url?" | |
if [ $? -eq 1 ] | |
then | |
wget --no-cookies --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com" $1 | |
filename=$(basename $1) | |
echo "Downloaded file $filename" | |
confirm "Untar file $filename?" | |
if [ $? -eq 1 ] | |
then | |
tar -xvvf $filename | |
rm $filename | |
javaFolder=$(find . -mindepth 1 -maxdepth 1 -type d) | |
confirm "Update to java $javaFolder?" | |
if [ $? -eq 1 ] | |
then | |
./../update-java $javaFolder | |
fi | |
fi | |
fi | |
# cleanup | |
cd .. | |
confirm "Delete temporary files?" | |
if [ $? -eq 1 ] | |
then | |
rm -R $tmp | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# JDK Folder must be placed in the same dir as this script. | |
# Folder name has to be passed in as the first and only parameter | |
cp -R $1 /usr/lib/jvm/ | |
echo "removing old symlink /usr/lib/jvm/java-7-sun" | |
rm /usr/lib/jvm/java-7-sun | |
echo "linking /usr/lib/jvm/java-7-sun to /usr/lib/jvm/$1" | |
ln -s /usr/lib/jvm/$1 /usr/lib/jvm/java-7-sun | |
echo "DONE" | |
java -version |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment