Skip to content

Commit 3ae3ac5

Browse files
author
Tom Barnes
committed
smarter defaulting for ORACLE_HOME, MW_HOME, and WL_HOME
1 parent a9b271a commit 3ae3ac5

File tree

4 files changed

+48
-20
lines changed

4 files changed

+48
-20
lines changed

operator/src/main/resources/scripts/introspectDomain.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@
2828
#
2929
# Prerequisites:
3030
#
31-
# - Optionally set WL_HOME - default is /u01/oracle/wlserver.
32-
#
33-
# - Optionally set MW_HOME - default is /u01/oracle.
31+
# - Optionally set
32+
# ORACLE_HOME = Oracle Install Home - defaults via utils.sh/exportInstallHomes
33+
# MW_HOME = MiddleWare Install Home - defaults to ${ORACLE_HOME}
34+
# WL_HOME = WebLogic Install Home - defaults to ${ORACLE_HOME}/wlserver
3435
#
3536
# - Transitively requires other env vars for startNodeManager.sh, wlst.sh,
3637
# and introspectDomain.py (see these scripts to find out what else needs to be set).
@@ -47,10 +48,9 @@ trace "Introspecting the domain"
4748

4849
env | tracePipe "Current environment:"
4950

50-
# set defaults
51+
# set ORACLE_HOME/WL_HOME/MW_HOME to defaults if needed
5152

52-
export WL_HOME=${WL_HOME:-/u01/oracle/wlserver}
53-
export MW_HOME=${MW_HOME:-/u01/oracle}
53+
exportInstallHomes
5454

5555
# check if prereq env-vars, files, and directories exist
5656

operator/src/main/resources/scripts/startNodeManager.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
#
2020
# SERVER_NAME = If not set, assumes this is introspector.
2121
#
22-
# WL_HOME = WebLogic Install Home - defaults to /u01/oracle/wlserver
22+
# ORACLE_HOME = Oracle Install Home - defaults via utils.sh/exportInstallHomes
23+
# MW_HOME = MiddleWare Install Home - defaults to ${ORACLE_HOME}
24+
# WL_HOME = WebLogic Install Home - defaults to ${ORACLE_HOME}/wlserver
2325
#
2426
# NODEMGR_LOG_HOME = Directory that will contain contain both
2527
# ${DOMAIN_UID}/${SERVER_NAME}_nodemanager.log
@@ -50,7 +52,8 @@ SCRIPTPATH="$( cd "$(dirname "$0")" > /dev/null 2>&1 ; pwd -P )"
5052
source ${SCRIPTPATH}/utils.sh
5153
[ $? -ne 0 ] && echo "[SEVERE] Missing file ${SCRIPTPATH}/utils.sh" && exit 1
5254

53-
export WL_HOME="${WL_HOME:-/u01/oracle/wlserver}"
55+
# Set ORACLE_HOME/WL_HOME/MW_HOME to defaults if needed
56+
exportInstallHomes
5457

5558
stm_script=${WL_HOME}/server/bin/startNodeManager.sh
5659

@@ -59,7 +62,7 @@ ADMIN_PORT_SECURE=${ADMIN_PORT_SECURE:-false}
5962

6063
trace "Starting node manager for domain-uid='$DOMAIN_UID' and server='$SERVER_NAME'."
6164

62-
checkEnv JAVA_HOME NODEMGR_HOME DOMAIN_HOME DOMAIN_UID WL_HOME || exit 1
65+
checkEnv JAVA_HOME NODEMGR_HOME DOMAIN_HOME DOMAIN_UID ORACLE_HOME MW_HOME WL_HOME || exit 1
6366

6467
if [ "${SERVER_NAME}" = "introspector" ]; then
6568
SERVICE_NAME=localhost

operator/src/main/resources/scripts/utils.sh

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,32 @@
33

44
#
55
# Purpose:
6-
# Define a trace function that matches the format of the trace function
7-
# in utils.py and of the logging in the java operator.
8-
#
9-
# Also define various shared utility functions.
6+
# Defines various shared utility functions, including a trace function.
107
#
118
# Load this file via the following pattern:
129
# SCRIPTPATH="$( cd "$(dirname "$0")" > /dev/null 2>&1 ; pwd -P )"
1310
# source ${SCRIPTPATH}/utils.sh
1411
# [ $? -ne 0 ] && echo "[SEVERE] Missing file ${SCRIPTPATH}/utils.sh" && exit 1
1512
#
1613

14+
# exportInstallHomes
15+
# purpose: export MW_HOME, WL_HOME, ORACLE_HOME
16+
# with defaults as needed
17+
function exportInstallHomes() {
18+
export ORACLE_HOME=${ORACLE_HOME:-${MW_HOME}}
19+
20+
if [ -z ${ORACLE_HOME} ]; then
21+
if [ -z ${WL_HOME} ]; then
22+
export ORACLE_HOME='/u01/oracle'
23+
else
24+
export ORACLE_HOME="`dirname ${WL_HOME}`"
25+
fi
26+
fi
27+
28+
export WL_HOME=${WL_HOME:-${ORACLE_HOME}/wlserver}
29+
export MW_HOME=${MW_HOME:-${ORACLE_HOME}}
30+
}
31+
1732
# timestamp
1833
# purpose: echo timestamp in the form yyyymmddThh:mm:ss.mmm ZZZ
1934
# example: 20181001T14:00:00.001 UTC
@@ -88,6 +103,11 @@ function trace() {
88103
else
89104
logLoc="`basename $0`:${BASH_LINENO[0]}"
90105
fi
106+
else
107+
if [ "$1" = "-cloc" ]; then
108+
shift
109+
shift
110+
fi
91111
fi
92112

93113
local logMode='-normal'
@@ -207,7 +227,7 @@ function checkEnv() {
207227

208228
#
209229
# exportEffectiveDomainHome
210-
# if DOMAIN_HOME='/u01/oracle/user_projects/domains':
230+
# if DOMAIN_HOME='${ORACLE_HOME}/user_projects/domains':
211231
# 1) look for a config.xml in DOMAIN_HOME/config and
212232
# and in DOMAIN_HOME/*/config
213233
# 2) Export DOMAIN_HOME to reflect the actual location
@@ -219,7 +239,9 @@ function exportEffectiveDomainHome() {
219239
local eff_domain_home=""
220240
local found_configs=""
221241

222-
if [ ! "${DOMAIN_HOME?}" = "/u01/oracle/user_projects/domains" ]; then
242+
exportInstallHomes
243+
244+
if [ ! "${DOMAIN_HOME?}" = "${ORACLE_HOME}/user_projects/domains" ]; then
223245
# nothing to do
224246
return 0
225247
fi

operator/src/main/resources/scripts/wlst.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
#
1010
# Input env vars:
1111
# - JAVA_HOME - required
12-
# - WL_HOME - optional - default is /u01/oracle/wlserver
13-
# - MW_HOME - optional - default is /u01/oracle
12+
# - Optionally set
13+
# ORACLE_HOME = Oracle Install Home - defaults via utils.sh/exportInstallHomes
14+
# MW_HOME = MiddleWare Install Home - defaults to ${ORACLE_HOME}
15+
# WL_HOME = WebLogic Install Home - defaults to ${ORACLE_HOME}/wlserver
1416
#
1517
# Usage:
1618
# SCRIPTPATH="$( cd "$(dirname "$0")" > /dev/null 2>&1 ; pwd -P )"
@@ -25,10 +27,11 @@ wlst_script=${1?}
2527

2628
trace "About to run wlst script '${wlst_script}'"
2729

28-
export WL_HOME=${WL_HOME:-/u01/oracle/wlserver}
29-
export MW_HOME=${MW_HOME:-/u01/oracle}
30+
# Set ORACLE_HOME/WL_HOME/MW_HOME to defaults if needed
31+
exportInstallHomes
3032

3133
checkEnv JAVA_HOME \
34+
ORACLE_HOME \
3235
WL_HOME \
3336
MW_HOME \
3437
|| exit 1
@@ -40,7 +43,7 @@ wlst_loc1="${WL_HOME}/../oracle_common/common/bin/wlst.sh"
4043
wlst_loc2="${MW_HOME}/oracle_common/common/bin/wlst.sh"
4144
[ -f "$wlst_loc2" ] && wlst_sh="$wlst_loc2"
4245
[ -f "$wlst_loc1" ] && wlst_sh="$wlst_loc1"
43-
[ -z "$wlst_sh" ] && trace SEVERE "'${wlst_loc1}' or '${wlst_loc2}' not found, make sure WL_HOME or MW_HOME is set correctly." && exit 1
46+
[ -z "$wlst_sh" ] && trace SEVERE "'${wlst_loc1}' or '${wlst_loc2}' not found, make sure ORACLE_HOME, WL_HOME, or MW_HOME is set correctly." && exit 1
4447

4548
trace "Running wlst script '${wlst_script}'"
4649

0 commit comments

Comments
 (0)