mq5.1-source.src.share.install.sys.mq.bin.init-config Maven / Gradle / Ivy
The newest version!
#!/bin/sh
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
# Copyright (c) 2000-2010 Oracle and/or its affiliates. All rights reserved.
#
# The contents of this file are subject to the terms of either the GNU
# General Public License Version 2 only ("GPL") or the Common Development
# and Distribution License("CDDL") (collectively, the "License"). You
# may not use this file except in compliance with the License. You can
# obtain a copy of the License at
# https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
# or packager/legal/LICENSE.txt. See the License for the specific
# language governing permissions and limitations under the License.
#
# When distributing the software, include this License Header Notice in each
# file and include the License file at packager/legal/LICENSE.txt.
#
# GPL Classpath Exception:
# Oracle designates this particular file as subject to the "Classpath"
# exception as provided by Oracle in the GPL Version 2 section of the License
# file that accompanied this code.
#
# Modifications:
# If applicable, add the following below the License Header, with the fields
# enclosed by brackets [] replaced by your own identifying information:
# "Portions Copyright [year] [name of copyright owner]"
#
# Contributor(s):
# If you wish your version of this file to be governed by only the CDDL or
# only the GPL Version 2, indicate your decision by adding "[Contributor]
# elects to include this software in this distribution under the [CDDL or GPL
# Version 2] license." If you don't indicate a single choice of license, a
# recipient has the option to distribute your version of this file under
# either the CDDL, the GPL Version 2 or to extend the choice of license to
# its licensees as provided above. However, if you add GPL Version 2 code
# and therefore, elected the GPL Version 2 license, then the option applies
# only if the new code is made subject to such option by the copyright
# holder.
#
#
# Post install configurator script for Message Queue.
# This script does:
# - JESMF registration
# - writes the JDK to use for MQ into the imqenv.conf file
#
MYDIR=`dirname $0`
cd ${MYDIR}
MYDIR=`pwd`
#
# This is the VM/CLASSPATH that was used to run the installer
#
INSTALLER_JAVA_HOME=${INIT_CONFIG_JAVA_HOME}
INSTALLER_JAVA_CLASSPATH=${CLASSPATH}:${INIT_CONFIG_JAVA_CLASSPATH}:${MYDIR}
#
# This is the VM that we want MQ to use. Currently hardcoded. This value/path
# will eventually be obtained from the PH framework.
#
IMQ_DEFAULT_JAVAHOME=/usr/jdk/instances/jdk1.5.0
RESET=
SILENT=
CONFIGSCHEMA=
CONFIGDATA=
VALIDATE=
CONFIG_STATUS=SUCCESS
PLATFORM_ERROR=None
PRODUCT_ERROR=None
DOC_REF=None
NEXT_STEPS=None
printResult() {
echo '' >&2
echo ''$1' ' >&2
echo ''$2' ' >&2
echo ''$3' ' >&2
echo ''$4' ' >&2
echo ''$5' ' >&2
echo ' ' >&2
}
usage() {
echo "### TBD: usage help ###"
}
# Set error codes returned by mqconfigmf script
setErrorCodes() {
INVALID_OS_ARCH=101
MFWKSETUP_CMD_NOT_FOUND=102
MQ_INSTALL_DIR_NOT_FOUND=103
COM_SUN_CMM_MQ_XML_NOT_FOUND=104
MFWK_CMD_FAILED=105
TOKEN_REPLACEMENT_FAILED=106
CACAOADM_CMD_NOT_FOUND=107
CACAO_NOT_RUNNING=108
USAGE_ERROR=109
}
checkOSAndInitVars() {
uName=`uname`
if [ "${uName}" = "SunOS" ]
then
initVarsSolaris
else if [ "${uName}" = "Linux" ]
then
initVarsLinux
else
CONFIG_STATUS=FAIL
echo "OS not supported"
printResult ${CONFIG_STATUS} "${PLATFORM_ERROR}" "${PRODUCT_ERROR}" "${DOC_REF}" "${NEXT_STEPS}"
exit 1
fi
fi
}
#
# Initializing the variables used in the script
# The relative paths from MQ_INSTALL_DIR is different for a given platform
#
initVarsSolaris() {
IMQENV_CONF=/etc/imq/imqenv.conf
UNINSTALL_PROP=/var/opt/install/contents/mq/uninstaller.properties
}
initVarsLinux() {
IMQENV_CONF=/etc/opt/sun/mq/imqenv.conf
UNINSTALL_PROP=/var/opt/sun/install/contents/mq/uninstaller.properties
}
#
# Perform actual configuration/unconfiguration
#
doWork() {
if [ -n "${RESET}" ] ; then
#
# Reset specified: unregister JESMF
#
${MYDIR}/mqconfigmf -u -j ${INSTALLER_JAVA_HOME}
RETVAL=$?
echo "RETVAL: ${RETVAL}"
if [ ! ${RETVAL} = 0 ]
then
case ${RETVAL} in
${MFWKSETUP_CMD_NOT_FOUND} | ${CACAOADM_CMD_NOT_FOUND})
DOC_REF="Java ES Monitoring Framework unregistration not performed - Monitoring Framework/Cacao utilities not found."
;;
${CACAO_NOT_RUNNING})
DOC_REF="Java ES Monitoring Framework unregistration not performed - Cacao management daemon not running."
;;
?) CONFIG_STATUS=FAIL
NEXT_STEPS="Please inspect the log and try to run the following command: ${MYDIR}/mqconfigmf -u -j ${INSTALLER_JAVA_HOME}."
;;
esac
fi
else
#
# Reset not specified: register JESMF
#
${MYDIR}/mqconfigmf -r -j ${INSTALLER_JAVA_HOME}
RETVAL=$?
if [ ! ${RETVAL} = 0 ]
then
case ${RETVAL} in
${MFWKSETUP_CMD_NOT_FOUND} | ${CACAOADM_CMD_NOT_FOUND})
DOC_REF="Java ES Monitoring Framework registration not performed - Monitoring Framework/Cacao utilities not found."
;;
${CACAO_NOT_RUNNING})
DOC_REF="Java ES Monitoring Framework registration not performed - Cacao management daemon not running."
;;
?) CONFIG_STATUS=FAIL
NEXT_STEPS="Please inspect the log and try to run the following command: ${MYDIR}/mqconfigmf -r -j ${INSTALLER_JAVA_HOME}."
;;
esac
fi
#
# Determine selected JDK_HOME
#
${INSTALLER_JAVA_HOME}/bin/java \
-cp "${INSTALLER_JAVA_CLASSPATH}" \
${INIT_CONFIG_HELPER_CLASS} \
-s ${CONFIGSCHEMA} \
-d ${CONFIGDATA} \
-o DECODE \
-f /tmp/mq.config.$$
IMQ_DEFAULT_JAVAHOME=`/bin/awk '/IMQ_SELECTED_JDK/ {getline; print}' /tmp/mq.config.$$`
/bin/rm -f /tmp/mq.config.$$
echo "User chose JDK: $IMQ_DEFAULT_JAVAHOME"
${INSTALLER_JAVA_HOME}/bin/java -cp ${INSTALLER_JAVA_CLASSPATH} SetupJDKHome -i ${IMQENV_CONF} -j "IMQ_DEFAULT_JAVAHOME=${IMQ_DEFAULT_JAVAHOME}"
RETVAL=$?
echo "RETVAL: ${RETVAL}"
if [ ! ${RETVAL} = 0 ]
then
CONFIG_STATUS=FAIL
if [ ${NEXT_STEPS} = ""]
then
NEXT_STEPS="Setting JDK in ${IMQENV_CONF} failed. Please edit this file manually."
else
NEXT_STEPS=${NEXT_STEPS}" Setting JDK in ${IMQENV_CONF} failed. Please edit this file manually."
fi
fi
${INSTALLER_JAVA_HOME}/bin/java -cp ${INSTALLER_JAVA_CLASSPATH} SetupJDKHome -i ${UNINSTALL_PROP} -j "${IMQ_DEFAULT_JAVAHOME}"
RETVAL=$?
echo "RETVAL: ${RETVAL}"
if [ ! ${RETVAL} = 0 ]
then
CONFIG_STATUS=FAIL
if [ ${NEXT_STEPS} = ""]
then
NEXT_STEPS="Setting JDK in ${UNINSTALL_PROP} failed. Please edit this file manually."
else
NEXT_STEPS=${NEXT_STEPS}" Setting JDK in ${UNINSTALL_PROP} failed. Please edit this file manually."
fi
fi
fi
}
#
# Perform validation - just set DOC_REF
#
doValidate() {
if [ -n "${RESET}" ] ; then
DOC_REF="Validation of MQ unconfigurator performed. No actual unconfiguration done."
else
DOC_REF="Validation of MQ configurator performed. No actual configuration done."
fi
}
########
# MAIN #
########
echo "init-config script for MQ"
echo "init-config: options passed: " $*
setErrorCodes
checkOSAndInitVars
OPTSTRING="f:d:rshv"
while getopts "${OPTSTRING}" opt; do
case ${opt} in
f) echo "-f specified with: " ${OPTARG}
CONFIGSCHEMA=${OPTARG}
;;
d) echo "-d specified with: " ${OPTARG}
CONFIGDATA=${OPTARG}
;;
h) usage
;;
r) RESET=true
;;
s) SILENT=true
;;
v) VALIDATE=true
;;
esac
done
if [ -n "${VALIDATE}" ] ; then
doValidate
else
doWork
fi
echo "CONFIG_STATUS: ${CONFIG_STATUS}"
echo "PLATFORM_ERROR: ${PLATFORM_ERROR}"
echo "PRODUCT_ERROR: ${PRODUCT_ERROR}"
echo "DOC_REF: ${DOC_REF}"
echo "NEXT_STEPS: ${NEXT_STEPS}"
printResult ${CONFIG_STATUS} "${PLATFORM_ERROR}" "${PRODUCT_ERROR}" "${DOC_REF}" "${NEXT_STEPS}"