Sdiff ids_register.ksh


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 # Copyright 2008 Sun Microsystems, Inc. All rights reserved. 23 # Use is subject to license terms. 24 # 25 #ident "@(#)ids_register.ksh 1.3 08/04/29 SMI" 26 # 27 # DO NOT EDIT THIS FILE 28 29 IDSDIR=/opt/SUNWscids/ 30 31 typeset opt 32 33 while getopts 'f:' opt 34 do 35 case "$opt" in 36 f) MYCONFIG=${OPTARG};; 37 *) /usr/bin/echo "ERROR: ${MYNAME} Option ${OPTARG} unknown" 38 /usr/bin/echo "Usage: ${MYNAME} -f <config file>" 39 exit 1;; 40 esac 41 done 42 43 [ -z "${MYCONFIG}" ] && MYCONFIG=/opt/SUNWscids/util/ids_config 44 45 . ${MYCONFIG} 46 47 for variable in RS RG USERID INFORMIXDIR ONCONFIG INFORMIXSERVER INFORMIXSQLHOSTS 48 do 49 if eval [ -z \$${variable} ] 50 then 51 /usr/bin/printf "ids requires a value for ${variable}= within ${MYCONFIG}\n" 52 rc=1 53 fi 54 done 55 56 [ "${rc}" -ne 0 ] && exit 1 57 58 if [ -z ${RS_ZONE} ] 59 then 60 61 /usr/cluster/bin/clrs create -g ${RG} -t SUNW.gds \ 62 -p Start_command="/opt/SUNWscids/bin/control_ids \ 63 -R '${RS}' -G '${RG}' -U '${USERID}' -D '${INFORMIXDIR}' -C '${ONCONFIG}' \ 64 -S '${INFORMIXSERVER}' -H '${INFORMIXSQLHOSTS}' start ids " \ 65 -p Stop_command="/opt/SUNWscids/bin/control_ids \ 66 -R '${RS}' -G '${RG}' -U '${USERID}' -D '${INFORMIXDIR}' -C '${ONCONFIG}' \ 67 -S '${INFORMIXSERVER}' -H '${INFORMIXSQLHOSTS}' stop ids " \ 68 -p Probe_command="/opt/SUNWscids/bin/control_ids \ 69 -R '${RS}' -G '${RG}' -U '${USERID}' -D '${INFORMIXDIR}' -C '${ONCONFIG}' \ 70 -S '${INFORMIXSERVER}' -H '${INFORMIXSQLHOSTS}' probe ids " \ 71 -p Validate_command="/opt/SUNWscids/bin/control_ids \ 72 -R '${RS}' -G '${RG}' -U '${USERID}' -D '${INFORMIXDIR}' -C '${ONCONFIG}' \ 73 -S '${INFORMIXSERVER}' -H '${INFORMIXSQLHOSTS}' validate ids " \ 74 -p Port_list=23/tcp -p Stop_signal=9 \ 75 -y Resource_dependencies=${HAS_RS},${LH_RS} \ 76 ${RS} 77 78 else 79 # Process a failover zone registration 80 # 81 # 1. Validate ${START_TIMEOUT} and ${STOP_TIMEOUT} 82 # 2. Get the failover zone's pfile and determine failover zone name 83 # 3. Build a temporary sczsmf_config file 84 # 4. zlogin to the failover zone execute ids_smf_register 85 # - Creates the SMF manifest using parameter values 86 # - Validate and import the SMF manifest into the SMF repository 87 # 5. Register a SC sczsmf resource to enable/disable the SMF instance 88 89 RS_STATE=`/usr/cluster/bin/scha_resource_get -O status -R ${RS}` 90 rc=$? 91 92 if [ "${rc}" -eq 0 ] 93 then 94 /usr/bin/printf "Sun Cluster resource ${RS} already exists\n" 95 /usr/bin/printf "Cleanup resource before retrying\n" 96 exit 1 97 fi 98 99 if ! [ "${START_TIMEOUT}" -ge 0 ] 2> /dev/null 100 then 101 /usr/bin/printf "START_TIMEOUT value is not an integer\n" 102 exit 1 103 fi 104 105 if ! [ "${STOP_TIMEOUT}" -ge 0 ] 2> /dev/null 106 then 107 /usr/bin/printf "STOP_TIMEOUT value is not an integer\n" 108 exit 1 109 fi 110 111 ZONEPFILE=`/usr/cluster/bin/clrs show -p Start_command ${RS_ZONE} | /usr/bin/grep -w Start_command | \ 112 /usr/bin/awk '{ if ($7 == "-P") print $8 }'` 113 114 if [ ! -d "${ZONEPFILE}" ] 115 then 116 /usr/bin/printf "Unable to retrieve zone parameter file directory\n" 117 exit 1 118 else 119 ZONE=`/usr/bin/grep Zonename= ${ZONEPFILE}/sczbt_${RS_ZONE} | /usr/bin/awk -F= '{print $2}' | /usr/xpg4/bin/tr -d '"' ` 120 fi 121 122 # VALIDATE RESOURCE 123 124 if /usr/sbin/zlogin ${ZONE} "/opt/SUNWscids/bin/control_ids -R '${RS}' -G '${RG}' -U '${USERID}' -D '${INFORMIXDIR}' -C '${ONCONFIG}' -S '${INFORMIXSERVER}' -H '${INFORMIXSQLHOSTS}' validate ids " 125 then 126 /usr/bin/printf "Validation of ${RS} succeeded\n" 127 else 128 /usr/bin/printf "Validation of ${RS} failed\n" 129 /usr/bin/printf "Check the syslog for ${ZONE}\n" 130 exit 1 131 fi 132 133 SERVICE_TAG=svc:/application/sczone-agents:${RS} 134 135 /usr/bin/cat > /var/tmp/${RS}_smf_config <<-EOF 136 RS=${RS} 137 RG=${RG} 138 SCZBT_RS=${RS_ZONE} 139 ZONE=${ZONE} 140 SERVICE=${SERVICE_TAG} 141 RECURSIVE=true 142 STATE=true 143 SERVICE_PROBE="/opt/SUNWscids/bin/control_ids probe ids ${SERVICE_TAG}" 144 EOF 145 146 TMP_WORK_CONFIG=/var/tmp/${RS}_tmp_work_config 147 /usr/bin/cat ${MYCONFIG} | /usr/sbin/zlogin ${ZONE} /usr/bin/cat - \> ${TMP_WORK_CONFIG} 148 149 # Remove an existing FMRI in the zone if it already exists 150 ${IDSDIR}/util/ids_smf_remove -z ${ZONE} -f ${SERVICE_TAG} 2>/dev/null 151 152 # Create and register the ${SERVICE_TAG} 153 if /usr/sbin/zlogin ${ZONE} ${IDSDIR}/util/ids_smf_register ${TMP_WORK_CONFIG} 154 then 155 if /opt/SUNWsczone/sczsmf/util/sczsmf_register -f /var/tmp/${RS}_smf_config 156 then 157 /usr/bin/printf "Registration of ${RS} succeeded\n" 158 159 if ! /usr/cluster/bin/clrs set -p Start_timeout=${START_TIMEOUT} ${RS} 160 then 161 /usr/bin/printf "clrs set -p Start_timeout=${START_TIMEOUT} ${RS} failed\n" 162 exit 1 163 fi 164 165 if ! /usr/cluster/bin/clrs set -p Stop_timeout=${STOP_TIMEOUT} ${RS} 166 then 167 /usr/bin/printf "clrs set -p Stop_timeout=${STOP_TIMEOUT} ${RS} failed\n" 168 exit 1 169 fi 170 else 171 /usr/bin/printf "Registration of ${RS} failed\n" 172 exit 1 173 fi 174 fi 175 fi 176 177 exit 0


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 # Copyright 2008 Sun Microsystems, Inc. All rights reserved. 23 # Use is subject to license terms. 24 # 25 #ident "@(#)ids_register.ksh 1.4 08/05/27 SMI" 26 # 27 # DO NOT EDIT THIS FILE 28 29 IDSDIR=/opt/SUNWscids/ 30 31 typeset opt 32 33 while getopts 'f:' opt 34 do 35 case "$opt" in 36 f) MYCONFIG=${OPTARG};; 37 *) /usr/bin/echo "ERROR: ${MYNAME} Option ${OPTARG} unknown" 38 /usr/bin/echo "Usage: ${MYNAME} -f <config file>" 39 exit 1;; 40 esac 41 done 42 43 [ -z "${MYCONFIG}" ] && MYCONFIG=/opt/SUNWscids/util/ids_config 44 45 . ${MYCONFIG} 46 47 for variable in RS RG LH_RS HAS_RS USERID INFORMIXDIR ONCONFIG INFORMIXSERVER INFORMIXSQLHOSTS 48 do 49 if eval [ -z \$${variable} ] 50 then 51 /usr/bin/printf "IDS requires a value for ${variable}= within ${MYCONFIG}\n" 52 rc=1 53 fi 54 done 55 56 [ "${rc}" -ne 0 ] && exit 1 57 58 /usr/cluster/bin/clrs create -g ${RG} -t SUNW.gds \ 59 -p Start_command="/opt/SUNWscids/bin/control_ids \ 60 -R '${RS}' -G '${RG}' -U '${USERID}' -D '${INFORMIXDIR}' -C '${ONCONFIG}' \ 61 -S '${INFORMIXSERVER}' -H '${INFORMIXSQLHOSTS}' start ids " \ 62 -p Stop_command="/opt/SUNWscids/bin/control_ids \ 63 -R '${RS}' -G '${RG}' -U '${USERID}' -D '${INFORMIXDIR}' -C '${ONCONFIG}' \ 64 -S '${INFORMIXSERVER}' -H '${INFORMIXSQLHOSTS}' stop ids " \ 65 -p Probe_command="/opt/SUNWscids/bin/control_ids \ 66 -R '${RS}' -G '${RG}' -U '${USERID}' -D '${INFORMIXDIR}' -C '${ONCONFIG}' \ 67 -S '${INFORMIXSERVER}' -H '${INFORMIXSQLHOSTS}' probe ids " \ 68 -p Validate_command="/opt/SUNWscids/bin/control_ids \ 69 -R '${RS}' -G '${RG}' -U '${USERID}' -D '${INFORMIXDIR}' -C '${ONCONFIG}' \ 70 -S '${INFORMIXSERVER}' -H '${INFORMIXSQLHOSTS}' validate ids " \ 71 -p Port_list=23/tcp -p Stop_signal=9 \ 72 -y Resource_dependencies=${HAS_RS},${LH_RS} \ 73 ${RS} 74 75 rc=$? 76 77 exit ${rc}