在 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
I have the scripts below to download, install or update Java on Linux OS such as CentOS.
Is there anything better than that around? It is a quite cumbersome script and I'd like a more elegant solution.
###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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
“改进”可以使用
yes
代替echo y >answers.txt
和...<答案.txt
。可能值得使用当前
0X
中的下一个数字检查是否有可用更新(以防 Oracle 不更改 distr 命名约定),然后下载并安装它。但我不确定它是否真的值得。An "improvement" can be using
yes
instead ofecho y >answers.txt
and...< answers.txt
.It may worth to check if an update is available using the next number from current
0X
(in case if oracle won't change distr naming convention) and then download and install it. But I'm not sure it really worths.