Ok, I must admit, I’m still a Linux newbie but love working in Linux environments. With that said, one of my recent goals was to bash script the installation of Java JDK 1.6 to an application server. I’ve failed in my attempt to run the installation bin file silently without prompting the user for any input. I’m still working on this process though if any of you readers have any pointers. A link to my post on this topic is below if you’d like to respond.
My alternative was to perform a manual install of the JDK.bin, zip up the files, then save it to a fileshare. A bash script calls this zipped jdk source as needed. The result is all of the destination app servers are configured exactly the same as the master. To zip the source, I used this command: zip -rv java_jdk_1.6.zip /local/java/jdk1.6.0_20/. Note my sample script below includes setting a custom environment variable as well as unzipping the JDK.
#!/bin/sh # Execute this bash script with: sh /directory_name/install_jdk1.6.sh # Using /local as parent destination in this example mkdir /local/java mkdir /local/java/jdk1.6.0_20 unzip /source_directory_name/jdk1.6.0_20.zip -d / # Note when I zipped the source jdk1.6.0_20 folder it included path info # Be careful about extracting files to / unless you know the full path # The next section creates a new profile for a custom environment variable # You can use the existing profile but I prefer leaving the original untouched # Add two lines to the end of bashrc to call custom profile echo "# Call custom app profile" >> /etc/bashrc echo ". /etc/profile.Z" >> /etc/bashrc # File extension of .Z means nothing except I know it's a customization # Begin profile.Z creation if [ ! -s /etc/profile.Z ] then cat << EOF > /etc/profile.Z # /etc/profile.Z : Custom .profile for the Bourne shell export JAVA_HOME=/local/java/jdk1.6.0_20 PATH=/local/java/jdk1.6.0_20/bin:$PATH:$HOME/bin export PATH EOF fi
That sums it up. I extract the JDK source compiled from a directory taken from a ‘master’ or working app server and then set the java environment variable in a custom profile. Bashrc is updated to reference the custom profile upon startup. Because of this, you will need to reboot the Linux box in order for the changes to take effect. Actually, I need to test that still, you may just need to log off of your current session and log back in. Try it I guess.*As stated, I’m far from a Linux expert so try this script and process at your own risk.