Chinaunix

标题: [提问]shell脚本自动化安装JDK的问题,难度挺大,大家看看 [打印本页]

作者: siemens84cn    时间: 2009-09-28 17:59
标题: [提问]shell脚本自动化安装JDK的问题,难度挺大,大家看看
编写一脚本,自动化实现对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]
作者: 寂寞烈火    时间: 2009-09-28 18:06
看看没坏处~~
作者: greendays    时间: 2009-09-28 18:45
标题: 回复 #1 siemens84cn 的帖子
你先完成手动安装,然后把安装后的目录打包。 在需要的地方解压就可以了。
作者: cxfcxf    时间: 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 编辑 ]
作者: siemens84cn    时间: 2009-09-29 09:28
非常感谢楼上的兄弟。思维被后缀bin限制了,以为是一个二进制的可执行文件,想不到是一个脚本。
作者: aqbssh    时间: 2009-09-29 09:43
标题: 回复 #4 cxfcxf 的帖子
看到了,长见识了。。。就像这种情况一样,很多时候所谓的问题,,全是我们自己的问题。我也一直以为.bin是二进制文件。
作者: siemens84cn    时间: 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来自动安装,所以,还是有人工交互的过程。




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2