Home | History | Annotate | Download | only in mgr
      1 #!/usr/bin/ksh
      2 #
      3 # CDDL HEADER START
      4 #
      5 # The contents of this file are subject to the terms of the
      6 # Common Development and Distribution License (the License).
      7 # You may not use this file except in compliance with the License.
      8 #
      9 # You can obtain a copy of the license at usr/src/CDDL.txt
     10 # or http://www.opensolaris.org/os/licensing.
     11 # See the License for the specific language governing permissions
     12 # and limitations under the License.
     13 #
     14 # When distributing Covered Code, include this CDDL HEADER in each
     15 # file and include the License file at usr/src/CDDL.txt.
     16 # If applicable, add the following below this CDDL HEADER, with the
     17 # fields enclosed by brackets [] replaced with your own identifying
     18 # information: Portions Copyright [yyyy] [name of copyright owner]
     19 #
     20 # CDDL HEADER END
     21 #
     22 
     23 #
     24 # Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
     25 # Use is subject to license terms.
     26 #
     27 #ident   "@(#)mgr_register.ksh 1.3     07/08/07 SMI"
     28 #
     29 #       DO NOT EDIT THIS FILE
     30 
     31 MQDIR=/opt/SUNWscmqs/
     32 COMPONENT=mgr
     33 
     34 TMP_WORK_CONFIG=/opt/SUNWscmqs/${COMPONENT}/util/.tmp_work_config
     35 typeset opt
     36 
     37 while getopts 'f:' opt
     38 do
     39 	case "$opt" in
     40 	   f)	MYCONFIG=${OPTARG};;
     41 	   *)	/usr/bin/echo "ERROR: ${MYNAME} Option ${OPTARG} unknown"
     42 		/usr/bin/echo "Usage: ${MYNAME} -f <config file>"
     43 		exit 1;;
     44 	esac
     45 done
     46 
     47 [ -z "${MYCONFIG}" ] && MYCONFIG=/opt/SUNWscmqs/${COMPONENT}/util/${COMPONENT}_config
     48 
     49 /usr/bin/cp ${MYCONFIG} ${TMP_WORK_CONFIG}
     50 . ${TMP_WORK_CONFIG}
     51 
     52 if [ -z ${RS_ZONE} ]
     53 then
     54 	### Process pre-S10, S10 global zone and S10 integrated zone registration ###
     55 	###           All parameter values get stored within the CCR              ###
     56 
     57 /usr/cluster/bin/scrgadm -a -j ${RS} -g ${RG} -t SUNW.gds \
     58 -x Start_command="/opt/SUNWscmqs/mgr/bin/start-qmgr \
     59 -R '${RS}' -G '${RG}' -Q '${QMGR}' -C '${CLEANUP}' -N '${SERVICES}' \
     60 -U '${USERID}' -D '${DB2INSTANCE}' -O '${ORACLE_HOME}' -I '${ORACLE_SID}' \
     61 -S '${START_CMD}' -E '${STOP_CMD}' " \
     62 -x Stop_command="/opt/SUNWscmqs/mgr/bin/stop-qmgr \
     63 -R '${RS}' -G '${RG}' -Q '${QMGR}' -C '${CLEANUP}' -N '${SERVICES}' \
     64 -U '${USERID}' -D '${DB2INSTANCE}' -O '${ORACLE_HOME}' -I '${ORACLE_SID}' \
     65 -S '${START_CMD}' -E '${STOP_CMD}' " \
     66 -x Probe_command="/opt/SUNWscmqs/mgr/bin/test-qmgr \
     67 -R '${RS}' -G '${RG}' -Q '${QMGR}' -C '${CLEANUP}' -N '${SERVICES}' \
     68 -U '${USERID}' -D '${DB2INSTANCE}' -O '${ORACLE_HOME}' -I '${ORACLE_SID}' \
     69 -S '${START_CMD}' -E '${STOP_CMD}' " \
     70 -y Port_list=1414/tcp -y Network_resources_used=${LH} \
     71 -x Stop_signal=9 \
     72 -y Resource_dependencies=${HAS_RS},${LSR_RS}
     73 
     74 else
     75 	###         Process S10 non-global (failover) zone registration           ###
     76 	###       All parameter values get stored within the SMF repository       ###
     77 
     78 	### 1. Validate ${TIMEOUT} is an integer, greater than or equal to 0      ###
     79 	### 2. Get the failover zone's pfile and determine failover zone name     ###
     80 	### 3. Build a temporary sczsmf_config file (i.e. /tmp/${RS}_smf_config)  ###
     81 	### 4. zlogin to the failover zone execute mqr_smf_register               ###
     82 	###    - Creates the SMF manifest using parameter values                  ###
     83 	###    - Validate and import the SMF manifest into the SMF repository     ###
     84 	### 5. Register a SC sczsmf resource to enable/disable the SMF instance   ###
     85 
     86 	RS_STATE=`/usr/cluster/bin/scha_resource_get -O status -R ${RS}`
     87 	rc=$?
     88 
     89 	if [ "${rc}" -eq 0 ]
     90 	then
     91 	   /usr/bin/printf "Sun Cluster resource ${RS} already exists\n"
     92 	   exit 1
     93 	fi
     94 
     95 	if ! [ "${TIMEOUT}" -ge 0 ] 2> /dev/null
     96 	then
     97 	   /usr/bin/printf "TIMEOUT value is not an integer\n"
     98 	   exit 1
     99 	fi
    100 	   
    101 	ZONEPFILE=`/usr/cluster/bin/scrgadm -pvv -j ${RS_ZONE} | /usr/bin/grep -w Start_command | \
    102 	   /usr/bin/grep -w value | /usr/bin/awk '{ if ($10 == "-P") print $11 }'`
    103 
    104 	if [ ! -d "${ZONEPFILE}" ]
    105 	then
    106 	   /usr/bin/printf "Unable to retrieve zone parameter file directory\n"
    107 	   exit 1
    108 	else
    109 	   ZONE=`/usr/bin/grep Zonename= ${ZONEPFILE}/sczbt_${RS_ZONE} | /usr/bin/awk -F= '{print $2}'`
    110 	fi
    111 
    112 	SERVICE_TAG=svc:/application/sczone-agents:${RS}
    113 
    114 	/usr/bin/cat > /tmp/${RS}_smf_config <<-EOF
    115 	RS=${RS}
    116 	RG=${RG}
    117 	SCZBT_RS=${RS_ZONE}
    118 	ZONE=${ZONE}
    119 	SERVICE=${SERVICE_TAG}
    120 	RECURSIVE=true
    121 	STATE=true
    122 	SERVICE_PROBE="/opt/SUNWscmqs/bin/control_wmqs test q${COMPONENT} ${SERVICE_TAG}"
    123 	EOF
    124 
    125 	# Remove an existing FMRI in the zone if it already exists
    126 	${MQDIR}/${COMPONENT}/util/${COMPONENT}_smf_remove -z ${ZONE} -f ${SERVICE_TAG} 2>/dev/null
    127 
    128 	if /usr/sbin/zlogin ${ZONE} ${MQDIR}/${COMPONENT}/util/${COMPONENT}_smf_register ${TMP_WORK_CONFIG}
    129 	then
    130 	   if RS_STATE=`/usr/cluster/bin/scha_resource_get -O status -R ${RS}`
    131 	   then
    132 		RS_STATE=`/usr/bin/echo ${RS_STATE} | /usr/bin/awk '{print $1}'`
    133 
    134 		if [ "${RS_STATE}" = "OFFLINE" ]
    135 		then
    136 		   /usr/bin/printf "${RS} already registered, but Offline\n"
    137 		   if /usr/cluster/bin/scrgadm -r -j ${RS}
    138 		   then
    139 			/usr/bin/printf "${RS} removed\n"
    140 		   else
    141 			/usr/bin/printf "Fix or cleanup resources before retrying\n"
    142 			exit 1
    143 		   fi
    144 		else
    145 		   /usr/bin/printf "${RS} already registered and is ${RS_STATE}\n"
    146 		   /usr/bin/printf "Registration of ${RS} failed\n"
    147 		   exit 1
    148 		fi
    149 	   fi
    150 
    151 	   if /opt/SUNWsczone/sczsmf/util/sczsmf_register -f /tmp/${RS}_smf_config
    152 	   then
    153 		/usr/bin/printf "Registration of ${RS} succeeded\n"
    154 	   else
    155 		/usr/bin/printf "Registration of ${RS} failed\n"
    156 		exit 1
    157 	   fi
    158 	fi
    159 
    160 	/usr/bin/rm ${TMP_WORK_CONFIG}
    161 fi
    162 
    163 exit 0
    164