Jason Yu
asked on
how could I change JAVA_HOME in all these files
I am upgrading the JAVA_HOME parameter in a oracle application server.
I need change the string JAVA_HOME="/usr/java/jdk1. 6.0_18" to JAVA_HOME="/usr/java/jdk1. 7.0_45" in all of the following files.
Is there a way I can make a script to backup each file and update each file.
Thanks.
[forms@solaris middleware]$ find . -type f -name "*.sh" -exec grep -il JAVA_HOME {} \;
./utils/clone/clone.sh
./utils/clone/restore.sh
./utils/uninstall/uninstal l.sh
./utils/bsu/bsu.sh
./utils/quickstart/quickst art.sh
./FormsHome/bin/runProvisi oningAntTa sks.sh
./FormsHome/sqldeveloper/i de/bin/lau ncher.sh
./FormsHome/oui/bin/runSSH Setup.sh
./oracle_common/sysman/dep loy/agentd eploy/remo teif/resou rces/scrip ts/sshConn ectivity.s h
./oracle_common/modules/or acle.ovd_1 1.1.1/oimt emplates/e xtendadsch ema.sh
./oracle_common/bin/SSLGen CA.sh
./oracle_common/bin/WLS_SS L_Client_C onfig.sh
./oracle_common/bin/pasteC onfig.sh
./oracle_common/bin/SSLSer verConfig. sh
./oracle_common/bin/libovd config.sh
./oracle_common/bin/pasteB inary.sh
./oracle_common/bin/libovd adaptercon fig.sh
./oracle_common/bin/extrac tMovePlan. sh
./oracle_common/bin/obfusc atePasswor d.sh
./oracle_common/bin/copyBi nary.sh
./oracle_common/bin/SSLCli entConfig. sh
./oracle_common/bin/WLS_SS L_Server_C onfig.sh
./oracle_common/bin/copyCo nfig.sh
./oracle_common/bin/OVD_SS L_Server_C onfig.sh
./oracle_common/common/bin /dfwhealth testctl.sh
./oracle_common/common/bin /was_confi g.sh
./oracle_common/common/bin /dfwhealth testadminc tl.sh
./oracle_common/common/bin /dfwhealth testcommon .sh
./oracle_common/jdk/db/bin /derby_com mon.sh
./oracle_common/oui/bin/ru nSSHSetup. sh
./wlserver_10.3/common/bin /config.sh
./wlserver_10.3/common/bin /pack.sh
./wlserver_10.3/common/bin /upgrade.s h
./wlserver_10.3/common/bin /config_bu ilder.sh
./wlserver_10.3/common/bin /wlst.sh
./wlserver_10.3/common/bin /wlscontro l.sh
./wlserver_10.3/common/bin /commEnv.s h
./wlserver_10.3/common/bin /unpack.sh
./wlserver_10.3/common/bin /startMana gedWebLogi c.sh
./wlserver_10.3/common/der by/bin/der by_common. sh
./wlserver_10.3/server/bin /setWLSEnv .sh
./wlserver_10.3/server/bin /startNode Manager.sh
./wlserver_10.3/server/lib /unix/node manager.sh
./user_projects/domains/Fo rmsDomain/ bin/nodema nager/wlsc ontrol.sh
./user_projects/domains/Fo rmsDomain/ bin/secure WebLogic.s h
./user_projects/domains/Fo rmsDomain/ bin/stopWe bLogic.sh
./user_projects/domains/Fo rmsDomain/ bin/startW ebLogic.sh
./user_projects/domains/Fo rmsDomain/ bin/setDom ainEnv.sh
[forms@solaris middleware]$
I need change the string JAVA_HOME="/usr/java/jdk1.
Is there a way I can make a script to backup each file and update each file.
Thanks.
[forms@solaris middleware]$ find . -type f -name "*.sh" -exec grep -il JAVA_HOME {} \;
./utils/clone/clone.sh
./utils/clone/restore.sh
./utils/uninstall/uninstal
./utils/bsu/bsu.sh
./utils/quickstart/quickst
./FormsHome/bin/runProvisi
./FormsHome/sqldeveloper/i
./FormsHome/oui/bin/runSSH
./oracle_common/sysman/dep
./oracle_common/modules/or
./oracle_common/bin/SSLGen
./oracle_common/bin/WLS_SS
./oracle_common/bin/pasteC
./oracle_common/bin/SSLSer
./oracle_common/bin/libovd
./oracle_common/bin/pasteB
./oracle_common/bin/libovd
./oracle_common/bin/extrac
./oracle_common/bin/obfusc
./oracle_common/bin/copyBi
./oracle_common/bin/SSLCli
./oracle_common/bin/WLS_SS
./oracle_common/bin/copyCo
./oracle_common/bin/OVD_SS
./oracle_common/common/bin
./oracle_common/common/bin
./oracle_common/common/bin
./oracle_common/common/bin
./oracle_common/jdk/db/bin
./oracle_common/oui/bin/ru
./wlserver_10.3/common/bin
./wlserver_10.3/common/bin
./wlserver_10.3/common/bin
./wlserver_10.3/common/bin
./wlserver_10.3/common/bin
./wlserver_10.3/common/bin
./wlserver_10.3/common/bin
./wlserver_10.3/common/bin
./wlserver_10.3/common/bin
./wlserver_10.3/common/der
./wlserver_10.3/server/bin
./wlserver_10.3/server/bin
./wlserver_10.3/server/lib
./user_projects/domains/Fo
./user_projects/domains/Fo
./user_projects/domains/Fo
./user_projects/domains/Fo
./user_projects/domains/Fo
[forms@solaris middleware]$
for file in $(find $MW_HOME -type f -name "*.sh" -exec grep -il JAVA_HOME {} \;)
do
sed -i.bak 's@JAVA_HOME="/usr/java/jd k1.6.0_18" @JAVA_HOME ="/usr/jav a/jdk1.7.0 _45"@' $file
done
The above will ceate a backup of each file (by appending ".bak") andthen change each file in place.
do
sed -i.bak 's@JAVA_HOME="/usr/java/jd
done
The above will ceate a backup of each file (by appending ".bak") andthen change each file in place.
ASKER
Could you please explain a little bit of the "sed" line?
Also, do I need put these three four lines in a script and execute it?
Also, do I need put these three four lines in a script and execute it?
ASKER
Can I also add a log file to this script so that I can check the result?
thanks.
thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
So you don't have to go through this again when you update Java, I suggest you change it to:
JAVA_HOME="/usr/java/lates t"
/usr/java/latest is a link to the latest Java package installed, and gets relinked whenever you update Java
JAVA_HOME="/usr/java/lates
/usr/java/latest is a link to the latest Java package installed, and gets relinked whenever you update Java
Good point, given that the "latest" version is indeed desired!
ASKER
Dear experts, thank you two for quick responds, I really appreciate your help.
I will run the script as you suggested.
tfewster;
For this case, I just can't use the symbolic link. As it was explained in oracle article (Doc ID 1309855.1):
SOLUTION
Alternatives
There are two different approaches that can be used to achieve the required goal. Both will be described briefly:
A) Installing a new JDK home, and then renaming the existing JDK directory
Please avoid using symlinks as previously suggested in this note, as tools such as T2P (test to production) do require a FULL JDK directory structure, and might fail if a symbolic link is used.
Following this approach, the JDK directory location originally used during the installation will not change , and hence it has the minimal drawback that it might keep a versioned name as for example "$INSTALL_HOME/jdk_<versio n>" while in truth it contains a new version. You may need to follow the next approach once to edit direcories to a generic name, but then able to update regularly by swapping out the contents of the jdk directory. (See the "Tips" in Note 1492980.1)
B) Installing a new JDK home directory and replacing the JAVA_HOME environmental variable in *** all *** the scripts referring to it.
This is the preferred approach if you want to do a partial upgrade (affecting to specific domains only, or not affecting to nodemanager), but its difficulty is around on how to know which files do refer to a JDK location.
The initial list of files to change will be :
* $INSTALL_HOME/wlserver_10. 3/common/b in/commEnv .sh
* $INSTALL_HOME/user_project s/domains/ <mydomain> /bin/setDo mainEnv.sh
* $INSTALL_HOME/wlserver_10. 3/common/n odemanager /nodemanag er.propert ies
* $INSTALL_HOME/utils/bsu/bs u.sh
* $INSTALL_HOME/utils/quicks tart/quick start.sh
* $INSTALL_HOME/utils/uninst all/uninst all.sh
even that a more exhaustive way to determine them, will be to run the following command:
find . -type f -name "*.sh" -exec grep -il JAVA_HOME {} \;
Step by Step Actions
I will run the script as you suggested.
tfewster;
For this case, I just can't use the symbolic link. As it was explained in oracle article (Doc ID 1309855.1):
SOLUTION
Alternatives
There are two different approaches that can be used to achieve the required goal. Both will be described briefly:
A) Installing a new JDK home, and then renaming the existing JDK directory
Please avoid using symlinks as previously suggested in this note, as tools such as T2P (test to production) do require a FULL JDK directory structure, and might fail if a symbolic link is used.
Following this approach, the JDK directory location originally used during the installation will not change , and hence it has the minimal drawback that it might keep a versioned name as for example "$INSTALL_HOME/jdk_<versio
B) Installing a new JDK home directory and replacing the JAVA_HOME environmental variable in *** all *** the scripts referring to it.
This is the preferred approach if you want to do a partial upgrade (affecting to specific domains only, or not affecting to nodemanager), but its difficulty is around on how to know which files do refer to a JDK location.
The initial list of files to change will be :
* $INSTALL_HOME/wlserver_10.
* $INSTALL_HOME/user_project
* $INSTALL_HOME/wlserver_10.
* $INSTALL_HOME/utils/bsu/bs
* $INSTALL_HOME/utils/quicks
* $INSTALL_HOME/utils/uninst
even that a more exhaustive way to determine them, will be to run the following command:
find . -type f -name "*.sh" -exec grep -il JAVA_HOME {} \;
Step by Step Actions
ASKER
Wonderful, I got the script running successfully. does the return code "0" mean it's successful?
------- Mon Sep 22 13:52:31 PDT 2014 -------
Now working on --- /u2/oracle/middleware/util s/clone/cl one.sh ---
Processed --- /u2/oracle/middleware/util s/clone/cl one.sh --- with returncode 0
Now working on --- /u2/oracle/middleware/util s/clone/re store.sh ---
Processed --- /u2/oracle/middleware/util s/clone/re store.sh --- with returncode 0
Now working on --- /u2/oracle/middleware/util s/uninstal l/uninstal l.sh ---
Processed --- /u2/oracle/middleware/util s/uninstal l/uninstal l.sh --- with returncode 0
Now working on --- /u2/oracle/middleware/util s/bsu/bsu. sh ---
Processed --- /u2/oracle/middleware/util s/bsu/bsu. sh --- with returncode 0
Now working on --- /u2/oracle/middleware/util s/quicksta rt/quickst art.sh ---
Processed --- /u2/oracle/middleware/util s/quicksta rt/quickst art.sh --- with returncode 0
Now working on --- /u2/oracle/middleware/Form sHome/bin/ runProvisi oningAntTa sks.sh ---
Processed --- /u2/oracle/middleware/Form sHome/bin/ runProvisi oningAntTa sks.sh --- with returncode 0
Now working on --- /u2/oracle/middleware/Form sHome/sqld eveloper/i de/bin/lau ncher.sh ---
Processed --- /u2/oracle/middleware/Form sHome/sqld eveloper/i de/bin/lau ncher.sh --- with returncode 0
Now working on --- /u2/oracle/middleware/Form sHome/oui/ bin/runSSH Setup.sh ---
Processed --- /u2/oracle/middleware/Form sHome/oui/ bin/runSSH Setup.sh --- with returncode 0
Now working on --- /u2/oracle/middleware/orac le_common/ sysman/dep loy/agentd eploy/remo teif/resou rces/scrip ts/sshConn ectivity.s h ---
Processed --- /u2/oracle/middleware/orac le_common/ sysman/dep loy/agentd eploy/remo teif/resou rces/scrip ts/sshConn ectivity.s h --- with returncode 0
Now working on --- /u2/oracle/middleware/orac le_common/ modules/or acle.ovd_1 1.1.1/oimt emplates/e xtendadsch ema.sh ---
Processed --- /u2/oracle/middleware/orac le_common/ modules/or acle.ovd_1 1.1.1/oimt emplates/e xtendadsch ema.sh --- with returncode 0
Now working on --- /u2/oracle/middleware/orac le_common/ bin/SSLGen CA.sh ---
Processed --- /u2/oracle/middleware/orac le_common/ bin/SSLGen CA.sh --- with returncode 0
Now working on --- /u2/oracle/middleware/orac le_common/ bin/WLS_SS L_Client_C onfig.sh ---
Processed --- /u2/oracle/middleware/orac le_common/ bin/WLS_SS L_Client_C onfig.sh --- with returncode 0
Now working on --- /u2/oracle/middleware/orac le_common/ bin/pasteC onfig.sh ---
Processed --- /u2/oracle/middleware/orac le_common/ bin/pasteC onfig.sh --- with re
------- Mon Sep 22 13:52:31 PDT 2014 -------
Now working on --- /u2/oracle/middleware/util
Processed --- /u2/oracle/middleware/util
Now working on --- /u2/oracle/middleware/util
Processed --- /u2/oracle/middleware/util
Now working on --- /u2/oracle/middleware/util
Processed --- /u2/oracle/middleware/util
Now working on --- /u2/oracle/middleware/util
Processed --- /u2/oracle/middleware/util
Now working on --- /u2/oracle/middleware/util
Processed --- /u2/oracle/middleware/util
Now working on --- /u2/oracle/middleware/Form
Processed --- /u2/oracle/middleware/Form
Now working on --- /u2/oracle/middleware/Form
Processed --- /u2/oracle/middleware/Form
Now working on --- /u2/oracle/middleware/Form
Processed --- /u2/oracle/middleware/Form
Now working on --- /u2/oracle/middleware/orac
Processed --- /u2/oracle/middleware/orac
Now working on --- /u2/oracle/middleware/orac
Processed --- /u2/oracle/middleware/orac
Now working on --- /u2/oracle/middleware/orac
Processed --- /u2/oracle/middleware/orac
Now working on --- /u2/oracle/middleware/orac
Processed --- /u2/oracle/middleware/orac
Now working on --- /u2/oracle/middleware/orac
Processed --- /u2/oracle/middleware/orac
Yes, returncode 0 means "OK". Congrats!
ASKER
woolmilkporc is best, his quick solution helped me achieve an important milestone.
ASKER