|
| 1 | +#!/usr/bin/env sh |
| 2 | +# ***************************************************************************** |
| 3 | +# doGenerateOffline.sh |
| 4 | +# |
| 5 | +# Copyright (c) 2021, 2022, Oracle and/or its affiliates. |
| 6 | +# The Universal Permissive License (UPL), Version 1.0 |
| 7 | +# |
| 8 | +# NAME |
| 9 | +# doGenerateOffline.sh - generate a JSON file with descriptions for the offline MBeans. |
| 10 | +# |
| 11 | +# DESCRIPTION |
| 12 | +# This script connects reads the domain home and collects the information about the different |
| 13 | +# MBeans that exist. |
| 14 | +# |
| 15 | +# This script uses the following command-line arguments directly, the rest |
| 16 | +# of the arguments are passed down to the underlying python program: |
| 17 | +# |
| 18 | +# - -oracle_home The location of the Oracle Home version for the generate job. |
| 19 | +# - -output_dir The location where to store the generated files and reports |
| 20 | +# and where to read the generated files to create the reports. |
| 21 | +# - -domain_home The directory where the domain is installed |
| 22 | +# - -status_dir The directory where the successful completion status file will be created. |
| 23 | +# |
| 24 | +# This script uses the following variables: |
| 25 | +# |
| 26 | +# JAVA_HOME - The location of the JDK to use. The caller must set |
| 27 | +# this variable to a valid Java 7 (or later) JDK. |
| 28 | +# |
| 29 | +# TEST_HOME - The location of the WLS Deploy Alias System Test installation. |
| 30 | +# |
| 31 | +# WLSDEPLOY_HOME - The location of the WLS Deploy installation. |
| 32 | +# |
| 33 | +# WLSDEPLOY_PROPERTIES - Extra system properties to pass to WLST. The caller |
| 34 | +# can use this environment variable to add additional |
| 35 | +# system properties to the WLST environment. |
| 36 | +# |
| 37 | + |
| 38 | +scriptPath="$(dirname "$0")" |
| 39 | +BASEDIR="$(pwd)" |
| 40 | + |
| 41 | +. "${scriptPath}/helpers.sh" |
| 42 | + |
| 43 | +WLSDEPLOY_PROGRAM_NAME="alias_test_generate_offline"; export WLSDEPLOY_PROGRAM_NAME |
| 44 | + |
| 45 | +if [ "${WLSDEPLOY_HOME}" = "" ]; then |
| 46 | + echo "WLSDEPLOY_HOME environment variable must be set" >&2 |
| 47 | + exit 1 |
| 48 | +fi |
| 49 | + |
| 50 | +if [ ! -d ${TEST_HOME} ]; then |
| 51 | + echo "Specified TEST_HOME of ${TEST_HOME} does not exist" |
| 52 | + exit 1 |
| 53 | +fi |
| 54 | + |
| 55 | +if [ "${JAVA_HOME}" = "" ]; then |
| 56 | + echo "Please set the JAVA_HOME environment variable to point to a Java installation compatible with the WebLogic version" >&2 |
| 57 | + exit 1 |
| 58 | +fi |
| 59 | + |
| 60 | +# |
| 61 | +# Find the args required to determine the WLST script to run |
| 62 | +# |
| 63 | +OUTPUT_DIR="${BASEDIR}/target" |
| 64 | +STATUS_DIR="" |
| 65 | + |
| 66 | +while [[ $# -gt 1 ]]; do |
| 67 | + key="$1" |
| 68 | + case $key in |
| 69 | + -oracle_home) |
| 70 | + ORACLE_HOME="$2" |
| 71 | + shift |
| 72 | + ;; |
| 73 | + -domain_home) |
| 74 | + DOMAIN_HOME="$2" |
| 75 | + shift |
| 76 | + ;; |
| 77 | + -output_dir) |
| 78 | + OUTPUT_DIR="$2" |
| 79 | + shift |
| 80 | + ;; |
| 81 | + -status_dir) |
| 82 | + STATUS_DIR="$2" |
| 83 | + shift |
| 84 | + ;; |
| 85 | + *) |
| 86 | + # unknown option |
| 87 | + ;; |
| 88 | + esac |
| 89 | + shift # past arg or value |
| 90 | +done |
| 91 | + |
| 92 | +# |
| 93 | +# Check for values of required arguments for this script to continue. |
| 94 | +# The underlying WLST script has other required arguments. |
| 95 | +# |
| 96 | +echo "ORACLE_HOME=${ORACLE_HOME}" |
| 97 | +if [ "${ORACLE_HOME}" = "" ]; then |
| 98 | + echo "Required argument -oracle_home not provided" >&2 |
| 99 | + exit 1 |
| 100 | +fi |
| 101 | + |
| 102 | +echo "DOMAIN_HOME=${DOMAIN_HOME}" |
| 103 | +if [ "${DOMAIN_HOME}" = "" ]; then |
| 104 | + echo "Required argument -domain_home not provided" >&2 |
| 105 | + exit 1 |
| 106 | +fi |
| 107 | + |
| 108 | +echo "OUTPUT_DIR=${OUTPUT_DIR}" |
| 109 | +mkdir -p "${OUTPUT_DIR}" |
| 110 | + |
| 111 | +if [ -z "${STATUS_DIR}" ]; then |
| 112 | + STATUS_DIR="${OUTPUT_DIR}/generate-status" |
| 113 | +fi |
| 114 | + |
| 115 | +# |
| 116 | +# Verify that the doGenerateSC and doGenerateOnline scripts completed successfully; otherwise, exit. |
| 117 | +# |
| 118 | +if [ ! -f "${STATUS_DIR}/doGenerateSC" ]; then |
| 119 | + echo "The doGenerateSC script status file ${STATUS_DIR}/doGenerateSC was not found so exiting" >&2 |
| 120 | + exit 1 |
| 121 | +elif [ ! -f "${STATUS_DIR}/doGenerateOnline" ]; then |
| 122 | + echo "The doGenerateOnline script status file ${STATUS_DIR}/doGenerateOnline was not found so exiting" >&2 |
| 123 | + exit 1 |
| 124 | +fi |
| 125 | + |
| 126 | +# |
| 127 | +# Find WLST |
| 128 | +# |
| 129 | +WLST= |
| 130 | +if [ -f "${ORACLE_HOME}/oracle_common/common/bin/wlst.sh" ]; then |
| 131 | + WLST="${ORACLE_HOME}/oracle_common/common/bin/wlst.sh" |
| 132 | + WLST_EXT_CLASSPATH="${WLSDEPLOY_HOME}/lib/weblogic-deploy-core.jar:${TEST_HOME}/resources"; export WLST_EXT_CLASSPATH |
| 133 | +elif [ -f "${ORACLE_HOME}/wlserver_10.3/common/bin/wlst.sh" ]; then |
| 134 | + WLST="${ORACLE_HOME}/wlserver_10.3/common/bin/wlst.sh" |
| 135 | +elif [ -f "${ORACLE_HOME}/wlserver_12.1/common/bin/wlst.sh" ]; then |
| 136 | + WLST="${ORACLE_HOME}/wlserver_12.1/common/bin/wlst.sh" |
| 137 | +elif [ -f "${ORACLE_HOME}/wlserver/common/bin/wlst.sh" ] && [ -f "${ORACLE_HOME}/wlserver/.product.properties" ]; then |
| 138 | + WLST="${ORACLE_HOME}/wlserver/common/bin/wlst.sh" |
| 139 | +else |
| 140 | + echo "Unable to locate wlst.sh script in ORACLE_HOME ${ORACLE_HOME}" >&2 |
| 141 | + exit 1 |
| 142 | +fi |
| 143 | + |
| 144 | +CLASSPATH="${WLSDEPLOY_HOME}/lib/weblogic-deploy-core.jar:${TEST_HOME}/resources" |
| 145 | + |
| 146 | +LOG_CONFIG_CLASS=oracle.weblogic.deploy.logging.WLSDeployLoggingConfig |
| 147 | +WLST_PROPERTIES=-Dcom.oracle.cie.script.throwException=true |
| 148 | +WLST_PROPERTIES="-Djava.util.logging.config.class=${LOG_CONFIG_CLASS} ${WLST_PROPERTIES}" |
| 149 | +WLST_PROPERTIES="${WLST_PROPERTIES} ${WLSDEPLOY_PROPERTIES}" |
| 150 | +export WLST_PROPERTIES |
| 151 | + |
| 152 | +if [ "${WLSDEPLOY_LOG_PROPERTIES}" = "" ]; then |
| 153 | + WLSDEPLOY_LOG_PROPERTIES=${WLSDEPLOY_HOME}/etc/logging.properties; export WLSDEPLOY_LOG_PROPERTIES |
| 154 | +fi |
| 155 | + |
| 156 | +if [ "${WLSDEPLOY_LOG_DIRECTORY}" = "" ]; then |
| 157 | + WLSDEPLOY_LOG_DIRECTORY=${WLSDEPLOY_HOME}/logs; export WLSDEPLOY_LOG_DIRECTORY |
| 158 | +fi |
| 159 | + |
| 160 | +echo "JAVA_HOME = ${JAVA_HOME}" |
| 161 | +echo "CLASSPATH = ${CLASSPATH}" |
| 162 | +echo "JAVA_PROPERTIES = ${JAVA_PROPERTIES}" |
| 163 | + |
| 164 | +PY_SCRIPTS_PATH=${TEST_HOME}/python |
| 165 | + |
| 166 | +echo "${WLST} ${PY_SCRIPTS_PATH}/generate_offline.py \ |
| 167 | + -oracle_home ${ORACLE_HOME} \ |
| 168 | + -domain_home ${DOMAIN_HOME} \ |
| 169 | + -output_dir ${OUTPUT_DIR}" |
| 170 | +"${WLST}" "${PY_SCRIPTS_PATH}/generate_offline.py" \ |
| 171 | + -oracle_home "${ORACLE_HOME}" \ |
| 172 | + -domain_home "${DOMAIN_HOME}" \ |
| 173 | + -output_dir "${OUTPUT_DIR}" |
| 174 | + |
| 175 | +RETURN_CODE=$? |
| 176 | +if [ "${RETURN_CODE}" = "0" ]; then |
| 177 | + echo "doGenerateOffline.sh completed successfully" |
| 178 | + touch "${STATUS_DIR}/doGenerateOffline" |
| 179 | +else |
| 180 | + echo "doGenerateOffline.sh failed (exit code = ${RETURN_CODE})" |
| 181 | +fi |
| 182 | +exit ${RETURN_CODE} |
0 commit comments