Automate Java installs on Unix
I'm currently working on self bootstrapping/configuring deployments for J2EE applications. My goal is to have the deployment install Java, App Server, and app deployment every time. Unfortunately I'm running into problems a开发者_如何学JAVAutomating the java install.
The java install is provided as a self-extracting binary (ie. jre-6u18-solaris-sparc.sh). The problem is when you run it you get prompted to read the license agreement and then enter yes/no.
In an attempt to automate I figured I would just uncompress the file using "unzip" and it expands, but something must either go wrong or some steps get skipped that happen when the self-extracting file is executed. When I go to run java, it complains that libraries are missing or other various error messages.
My currently planned work around is to download and install manually, then zip up the extracted content and host the modified distribution internally. Not ideal b/c I'm no longer working with the original distribution from SUN.
The installer scripts may vary on each platform but on Linux, there are 3 hurdles you need to overcome:
- Spacing through the long EULA
- Entering "yes" to accept the EULA
- Pressing Enter after the install is done.
You can get away with this by echoing yes and a newline in to the script while redirecting stdout to /dev/null
so that the EULA isn't printed:
echo "yes" "\n" | ./jdk-6u16-linux-i586.bin 1>/dev/null
You may have to tweak this on Solaris
Would you not consider using the 'expect' script to do that...instead of doing it the awkward way, the script will simply enter a 'Yes' when it comes to the agreement page...the download link is here. Effectively a wrapper using expect containing the package...
Hope this helps, Best regards, Tom.
Have a look at how Hudson does it. It can dynamically download and install at least Java 1.4, 5 and 6 from Sun in the background.
精彩评论