6
我有下面的腳本來下載,安裝或更新Linux操作系統(如CentOS)上的Java。 還有什麼比周圍更好?這是一個非常繁瑣的腳本,我想要一個更優雅的解決方案。在沒有提示的情況下在Linux/CentOS上安裝並升級Java
###INSTALL
wget http://www.java.net/download/jdk7/binaries/jdk-7-ea-bin-b96-linux-x64-03_jun_2010.bin
chmod a+x jdk-7-ea-bin-b96-linux-x64-03_jun_2010.bin
echo y > answers.txt
./jdk-7-ea-bin-b96-linux-x64-03_jun_2010.bin < answers.txt &>/dev/null
mkdir /jdk7
mv /root/jdk1.7.0 /jdk7
ln -sf /jdk7/bin/java /usr/bin/java
rm -f jdk-7-ea-bin-b96-linux-x64-03_jun_2010.bin
###UPGRADE
wget http://www.java.net/download/jdk7/binaries/jdk-7-ea-bin-b117-linux-x64-04_nov_2010.bin
chmod a+x jdk-7-ea-bin-b117-linux-x64-04_nov_2010.bin
echo y > answers.txt
rm -rf /jdk7
./jdk-7-ea-bin-b96-linux-x64-03_jun_2010.bin < answers.txt &>/dev/null
mv /root/jdk1.7.0 /jdk7
ln -sf /jdk7/bin/java /usr/bin/java
rm -f jdk-7-ea-bin-b96-linux-x64-03_jun_2010.bin