免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 4204 | 回复: 6
打印 上一主题 下一主题

[提问]shell脚本自动化安装JDK的问题,难度挺大,大家看看 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-09-28 17:59 |只看该作者 |倒序浏览
编写一脚本,自动化实现对jdk的安装:
#!/bin/bash
/bin/bash jdk-6u12-linux-i586.bin << EOF
no
EOF

问题来了,jdk安装,会出现license的阅读,需要使用键盘输入若干个空格或者一个“q”才能进入yes/no选项,对于这种情况,大家有什么好方法?

我帖一下执行jdk安装程序后的内容:
suse10test:/home # ./jdk-6u12-linux-i586.bin
Sun Microsystems, Inc. Binary Code License Agreement

for the JAVA SE DEVELOPMENT KIT (JDK), VERSION 6

SUN MICROSYSTEMS, INC. ("SUN") IS WILLING TO LICENSE THE
SOFTWARE IDENTIFIED BELOW TO YOU ONLY UPON THE CONDITION
THAT YOU ACCEPT ALL OF THE TERMS CONTAINED IN THIS BINARY
CODE LICENSE AGREEMENT AND SUPPLEMENTAL LICENSE TERMS
(COLLECTIVELY "AGREEMENT"). PLEASE READ THE AGREEMENT
CAREFULLY. BY DOWNLOADING OR INSTALLING THIS SOFTWARE, YOU
ACCEPT THE TERMS OF THE AGREEMENT. INDICATE ACCEPTANCE BY
SELECTING THE "ACCEPT" BUTTON AT THE BOTTOM OF THE
AGREEMENT. IF YOU ARE NOT WILLING TO BE BOUND BY ALL THE
TERMS, SELECT THE "DECLINE" BUTTON AT THE BOTTOM OF THE
AGREEMENT AND THE DOWNLOAD OR INSTALL PROCESS WILL NOT
CONTINUE.

1. DEFINITIONS. "Software" means the identified above in
binary form, any other machine readable materials
(including, but not limited to, libraries, source files,
header files, and data files), any updates or error
corrections provided by Sun, and any user manuals,
programming guides and other documentation provided to you
by Sun under this Agreement.  "General Purpose Desktop
Computers and Servers" means computers, including desktop,
laptop and tablet computers, or servers, used for general
computing functions under end user control (such as but not
specifically limited to email, general purpose Internet
browsing, and office suite productivity tools).
The use of Software in systems and solutions that provide
dedicated functionality (other than as mentioned above) or
designed for use in embedded or function-specific software
applications, for example but not limited to: Software
embedded in or bundled with industrial control systems,
wireless mobile telephones, wireless handheld devices,
kiosks, TV/STB, Blu-ray Disc devices, telematics and
network control switching equipment, printers and storage
management systems, and other related systems are excluded
from this definition and not licensed under this
Agreement.  "Programs" means Java technology applets and
applications intended to run on the Java Platform Standard
Edition (Java SE) platform on Java-enabled General Purpose
Desktop Computers and Servers.
--More--
出现了more,你就需要输入若干个空格,或者输入一个q,才能进入如下选项:
Do you agree to the above license terms? [yes or no]

论坛徽章:
1
荣誉会员
日期:2011-11-23 16:44:17
2 [报告]
发表于 2009-09-28 18:06 |只看该作者
看看没坏处~~

论坛徽章:
0
3 [报告]
发表于 2009-09-28 18:45 |只看该作者

回复 #1 siemens84cn 的帖子

你先完成手动安装,然后把安装后的目录打包。 在需要的地方解压就可以了。

论坛徽章:
0
4 [报告]
发表于 2009-09-29 03:52 |只看该作者
这个bin文件其实是一个shell+ELF 你可以改开始的脚本的

#file jdk-6u16-linux-i586.bin
jdk-6u16-linux-i586.bin: POSIX shell script text executable


你用vi打开自己改

  1. diskSpaceRequired=259060
  2. more <<"EOF"
  3. Sun Microsystems, Inc. Binary Code License Agreement

  4. for the JAVA SE DEVELOPMENT KIT (JDK), VERSION 6
  5. ..
  6. ..
复制代码

看到EOF哪行字了么 吧这行改成

  1. cat << "EOF"
复制代码


就是你的要求了

你愿意可以把所有判断yes和no的全部改成不判断的 呵呵

[ 本帖最后由 cxfcxf 于 2009-9-29 08:48 编辑 ]

论坛徽章:
0
5 [报告]
发表于 2009-09-29 09:28 |只看该作者
非常感谢楼上的兄弟。思维被后缀bin限制了,以为是一个二进制的可执行文件,想不到是一个脚本。

论坛徽章:
3
天蝎座
日期:2013-11-11 10:18:392015年亚洲杯之沙特阿拉伯
日期:2015-04-06 15:51:08CU十四周年纪念徽章
日期:2017-01-07 22:56:29
6 [报告]
发表于 2009-09-29 09:43 |只看该作者

回复 #4 cxfcxf 的帖子

看到了,长见识了。。。就像这种情况一样,很多时候所谓的问题,,全是我们自己的问题。我也一直以为.bin是二进制文件。

论坛徽章:
0
7 [报告]
发表于 2009-11-12 14:27 |只看该作者
原帖由 cxfcxf 于 2009-9-29 03:52 发表
这个bin文件其实是一个shell+ELF 你可以改开始的脚本的

#file jdk-6u16-linux-i586.bin
jdk-6u16-linux-i586.bin: POSIX shell script text executable


你用vi打开自己改

diskSpaceRequired=259060 ...


To cxfcxf,我突然发现,JDK在执行的时候,会去做校验和的行为,这样修改后,导致checksum与原先不符,导致执行失败。
从目前来看,jdk的包是无允许随便更改的。

我目前的操作是,先人工对*.bin包解压,然后把取出的rpm来自动安装,所以,还是有人工交互的过程。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP