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 "@(#)chi_register.ksh 1.3 07/08/07 SMI" 28 # 29 # DO NOT EDIT THIS FILE 30 31 MQDIR=/opt/SUNWscmqs/ 32 COMPONENT=chi 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 scrgadm -a -j ${RS} -g ${RG} -t SUNW.gds \ 58 -x Start_command="/opt/SUNWscmqs/chi/bin/start-chi \ 59 -R '${RS}' -G '${RG}' -Q '${QMGR}' -I '${CHIQ}' -U '${USERID}' " \ 60 -x Stop_command="/opt/SUNWscmqs/chi/bin/stop-chi \ 61 -R '${RS}' -G '${RG}' -Q '${QMGR}' -I '${CHIQ}' -U '${USERID}' " \ 62 -x Probe_command="/opt/SUNWscmqs/chi/bin/test-chi \ 63 -R '${RS}' -G '${RG}' -Q '${QMGR}' -I '${CHIQ}' -U '${USERID}' " \ 64 -y Port_list=1414/tcp -x Network_aware=FALSE \ 65 -x Stop_signal=9 -y Failover_mode=NONE -x Failover_enabled=FALSE \ 66 -y Resource_dependencies=${QMGR_RS} 67 68 else 69 ### Process S10 non-global (failover) zone registration ### 70 ### All parameter values get stored within the SMF repository ### 71 72 ### 1. Get the failover zone's pfile and determine failover zone name ### 73 ### 2. Build a temporary sczsmf_config file (i.e. /tmp/${RS}_smf_config) ### 74 ### 3. zlogin to the failover zone execute mqr_smf_register ### 75 ### - Creates the SMF manifest using parameter values ### 76 ### - Validate and import the SMF manifest into the SMF repository ### 77 ### 4. Register a SC sczsmf resource to enable/disable the SMF instance ### 78 79 RS_STATE=`/usr/cluster/bin/scha_resource_get -O status -R ${RS}` 80 rc=$? 81 82 if [ "${rc}" -eq 0 ] 83 then 84 /usr/bin/printf "Sun Cluster resource ${RS} already exists\n" 85 exit 1 86 fi 87 88 ZONEPFILE=`/usr/cluster/bin/scrgadm -pvv -j ${RS_ZONE} | /usr/bin/grep -w Start_command | \ 89 /usr/bin/grep -w value | /usr/bin/awk '{ if ($10 == "-P") print $11 }'` 90 91 if [ ! -d "${ZONEPFILE}" ] 92 then 93 /usr/bin/printf "Unable to retrieve zone parameter file directory\n" 94 exit 1 95 else 96 ZONE=`/usr/bin/grep Zonename= ${ZONEPFILE}/sczbt_${RS_ZONE} | /usr/bin/awk -F= '{print $2}'` 97 fi 98 99 SERVICE_TAG=svc:/application/sczone-agents:${RS} 100 101 /usr/bin/cat > /tmp/${RS}_smf_config <<-EOF 102 RS=${RS} 103 RG=${RG} 104 SCZBT_RS=${RS_ZONE} 105 ZONE=${ZONE} 106 SERVICE=${SERVICE_TAG} 107 RECURSIVE=true 108 STATE=true 109 SERVICE_PROBE="/opt/SUNWscmqs/bin/control_wmqs test ${COMPONENT} ${SERVICE_TAG}" 110 EOF 111 112 # Remove an existing FMRI in the zone if it already exists 113 ${MQDIR}/${COMPONENT}/util/${COMPONENT}_smf_remove -z ${ZONE} -f ${SERVICE_TAG} 2>/dev/null 114 115 if /usr/sbin/zlogin ${ZONE} ${MQDIR}/${COMPONENT}/util/${COMPONENT}_smf_register ${TMP_WORK_CONFIG} 116 then 117 if RS_STATE=`/usr/cluster/bin/scha_resource_get -O status -R ${RS}` 118 then 119 RS_STATE=`/usr/bin/echo ${RS_STATE} | /usr/bin/awk '{print $1}'` 120 121 if [ "${RS_STATE}" = "OFFLINE" ] 122 then 123 /usr/bin/printf "${RS} already registered, but Offline\n" 124 if /usr/cluster/bin/scrgadm -r -j ${RS} 125 then 126 /usr/bin/printf "${RS} removed\n" 127 else 128 /usr/bin/printf "Fix or cleanup resources before retrying\n" 129 exit 1 130 fi 131 else 132 /usr/bin/printf "${RS} already registered and is ${RS_STATE}\n" 133 /usr/bin/printf "Registration of ${RS} failed\n" 134 exit 1 135 fi 136 fi 137 138 if /opt/SUNWsczone/sczsmf/util/sczsmf_register -f /tmp/${RS}_smf_config 139 then 140 /usr/bin/printf "Registration of ${RS} succeeded\n" 141 else 142 /usr/bin/printf "Registration of ${RS} failed\n" 143 exit 1 144 fi 145 fi 146 147 /usr/bin/rm ${TMP_WORK_CONFIG} 148 fi 149 150 exit 0 151