#!/bin/bash
# Purpose : For changing JDK version to 1.6.0_14 non-interactively. This script could be useful for
# changing the JDK version automatically on multiple servers. I have used this script in a
# production change where we got to update JDK version simultaneously on 60+ servers.
# Assumption : The Binary version of JDK version 1.6.0_14 already installed under /usr/java/jdk1.6.0_14"
/usr/sbin/alternatives --install /usr/bin/java java /usr/java/jdk1.6.0_14/bin/java 1
/usr/sbin/alternatives --set java /usr/java/jdk1.6.0_14/bin/java
/usr/sbin/alternatives --install /usr/bin/javac javac /usr/java/jdk1.6.0_14/bin/javac 1
/usr/sbin/alternatives --set javac /usr/java/jdk1.6.0_14/bin/javac
unlink /usr/bin/java
ln -s /usr/java/jdk1.6.0_14/bin/java /usr/bin/java
sed -i.bak '/export/ i JAVA_HOME=/usr/java/jdk1.6.0_14\nPATH=$PATH:$JAVA_HOME/bin\nJAVAPTH=$JAVA_HOME/bin\n' /etc/profile
sed -i.bak 's/export.*$/export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC JAVA_HOME JAVAPTH/' /etc/profile
java -version 2&> java_ver
java_ver=`cat java_ver | grep java | cut -c 15-22`
if [ "$java_ver" != "1.6.0_14" ]; then
echo -e "Updating JDK version to 1.6.0_14 Failed. Please check manually.\n"
exit 1
else
rm -f ./java_ver
echo -e "\n\n\nJDK version has been successfully changed to 1.6.0_14.\n\n"
fi
# Purpose : For changing JDK version to 1.6.0_14 non-interactively. This script could be useful for
# changing the JDK version automatically on multiple servers. I have used this script in a
# production change where we got to update JDK version simultaneously on 60+ servers.
# Assumption : The Binary version of JDK version 1.6.0_14 already installed under /usr/java/jdk1.6.0_14"
/usr/sbin/alternatives --install /usr/bin/java java /usr/java/jdk1.6.0_14/bin/java 1
/usr/sbin/alternatives --set java /usr/java/jdk1.6.0_14/bin/java
/usr/sbin/alternatives --install /usr/bin/javac javac /usr/java/jdk1.6.0_14/bin/javac 1
/usr/sbin/alternatives --set javac /usr/java/jdk1.6.0_14/bin/javac
unlink /usr/bin/java
ln -s /usr/java/jdk1.6.0_14/bin/java /usr/bin/java
sed -i.bak '/export/ i JAVA_HOME=/usr/java/jdk1.6.0_14\nPATH=$PATH:$JAVA_HOME/bin\nJAVAPTH=$JAVA_HOME/bin\n' /etc/profile
sed -i.bak 's/export.*$/export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC JAVA_HOME JAVAPTH/' /etc/profile
java -version 2&> java_ver
java_ver=`cat java_ver | grep java | cut -c 15-22`
if [ "$java_ver" != "1.6.0_14" ]; then
echo -e "Updating JDK version to 1.6.0_14 Failed. Please check manually.\n"
exit 1
else
rm -f ./java_ver
echo -e "\n\n\nJDK version has been successfully changed to 1.6.0_14.\n\n"
fi
No comments:
Post a Comment