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 2008 Sun Microsystems, Inc. All rights reserved. 25 # Use is subject to license terms. 26 # 27 # ident "@(#)control_ebs.ksh 1.9 08/08/06 SMI" 28 # 29 # Usage GDS: <options> <parameter1> <parameter2> 30 # 31 # <options>: -R <resource> -G <resourcegroup> etc. 32 # parameter1: start | stop | probe | validate 33 # parameter2: cmg | cmglsr | frm | opmn | rep 34 35 MYNAME=`basename $0` 36 MYDIR=`dirname $0` 37 38 typeset opt 39 40 while getopts 'R:G:C:U:P:S:V:O:L:M:X:' opt 41 do 42 case "${opt}" in 43 R) RESOURCE=${OPTARG};; 44 G) RESOURCEGROUP=${OPTARG};; 45 C) COMNTOP=${OPTARG};; 46 U) APPSUSER=${OPTARG};; 47 P) APPS_PASSWD=${OPTARG};; 48 S) APP_SID=${OPTARG};; 49 V) VERSION=${OPTARG};; 50 O) ORACLE_HOME=${OPTARG};; 51 L) CON_LIMIT=${OPTARG};; 52 M) # Backward compatability 53 ;; 54 X) OPMN_COMPONENTS=${OPTARG};; 55 56 *) exit 1;; 57 esac 58 done 59 60 if [ "${OPTIND}" -gt 1 ] 61 then 62 # Called by GDS 63 CALLER=GDS 64 65 shift $((${OPTIND} -1)) 66 else 67 # Called by SMF 68 exit 1 69 fi 70 71 METHOD=${1} 72 COMPONENT=${2} 73 74 . ${MYDIR}/../${COMPONENT}/etc/config 75 . ${MYDIR}/functions 76 77 debug_message "Method: ${MYNAME} - Begin" 78 ${SET_DEBUG} 79 80 if [ "${CALLER}" = "GDS" ] 81 then 82 # Perform all the scha* calls 83 TASK_COMMAND="" 84 85 # The docs require that the user creates a symlink from 86 # /usr/cluster/lib/libschost.so.1 to /usr/lib/secure/libschost.so.1 87 # 88 # Additionally, refer to the security section within the 89 # libschost.so.1(1) man page. 90 91 LDPRELOAD="LD_PRELOAD_32=/usr/lib/secure/libschost.so.1" 92 93 if [ "${METHOD}" = "stop" ] 94 then 95 STOP_TIMEOUT=`/usr/cluster/bin/scha_resource_get -O Stop_timeout \ 96 -R ${RESOURCE} -G ${RESOURCEGROUP} ` 97 fi 98 99 SCLH=`/usr/cluster/bin/scha_resource_get -O Network_resources_used \ 100 -R ${RESOURCE} -G ${RESOURCEGROUP} ` 101 102 # If ${SCLH} is empty the VALIDATE method is running at resource creation. 103 # In order to determine the correct SUNW.LogicalHostname resource associated 104 # with the resource being created, the /var/cluster/logs/commandlog is used. 105 # Note, this is a one time activity as once the resource is created then 106 # scha_resource_get will derive the corect Network_resources_used. 107 108 if [ ${#SCLH} -eq 0 ] 109 then 110 SCLH_LIST=$(/usr/bin/tail -3 /var/cluster/logs/commandlog | /usr/bin/grep START | \ 111 /usr/bin/grep ${RESOURCE} | /usr/bin/grep Resource_dependencies_restart= |\ 112 /usr/bin/sed -e 's/^.*-y "Resource_dependencies_restart=//' | /usr/bin/awk '{print $1}' |\ 113 /usr/bin/tr -d '"' | /usr/bin/tr ',' ' ') 114 115 for res in ${SCLH_LIST} 116 do 117 RT=$(/usr/cluster/bin/scha_resource_get -O Type -R ${res} -G ${RESOURCEGROUP}) 118 119 if /usr/bin/echo ${RT} | /usr/xpg4/bin/grep -q SUNW.LogicalHostname 120 then 121 SCLH=${res} 122 debug_message "control_ebs - SCLH=${res} retrieved from commandlog" 123 break 124 fi 125 done 126 127 if [ ${#SCLH} -eq 0 ] 128 then 129 # SCMSGS 130 # @explanation 131 # Unable to determine the SUNW.LogicalHostname resource within the 132 # Resource_dependencies list for the resource being created. 133 # @user_action 134 # Check that you have specified a value for the LH keyword within the 135 # /opt/SUNWscebs/xxx/util/xxx_config, where xxx represents the Oracle 136 # E-Business Suite component - cmg, cmglsr, frm, opmn and rep. 137 scds_syslog -p daemon.err -t $(syslog_tag) -m \ 138 "Validate - Unable to determine the SUNW.LogicalHostname resource for %s" \ 139 "${RESOURCE}" 140 return 1 141 fi 142 fi 143 144 LHOST=`/usr/cluster/bin/scha_resource_get -O Extension -R ${SCLH} -G ${RESOURCEGROUP} \ 145 HostnameList | /usr/bin/tail +2` 146 147 LHOSTNAME="SC_LHOSTNAME=${LHOST}" 148 149 # Because EBS v12 introduces changes to the pathname for the admin scripts, we set the 150 # appropriate scripts pathname here. Also to maintain backward compatability we still 151 # use ${COMNTOP}. 152 153 case "${VERSION}" in 154 11.5.8) debug_message "Validate - ${VERSION}" 155 # With 11.5.8 the SID didn't change 156 SID=${APP_SID} 157 ADSCRIPT_PATH=${COMNTOP}/admin/scripts/${APP_SID} 158 ;; 159 11.5.*) debug_message "Validate - ${VERSION}" 160 # With 11.5.9 the SID changed to SID_<lhost> 161 # for some directory structures and files 162 SID=${APP_SID} 163 APP_SID=${APP_SID}_${LHOST} 164 ADSCRIPT_PATH=${COMNTOP}/admin/scripts/${APP_SID} 165 ;; 166 12.*) debug_message "Validate - ${VERSION}" 167 # With 12.0 the pathname to the admin scripts changes 168 # from ${COMNTOP}/admin/scripts/${APP_SID} 169 # to <basedir>/inst/apps/${APP_SID}/admin/scripts 170 # where <basedir> = s_base variable within the 171 # conf_<SID>.txt file built by rapidwiz. 172 # Nevertheless we will use a relative pathname from ${COMNTOP}. 173 SID=${APP_SID} 174 APP_SID=${APP_SID}_${LHOST} 175 ADSCRIPT_PATH=${COMNTOP}/../../../inst/apps/${APP_SID}/admin/scripts 176 ;; 177 *) scds_syslog -p daemon.err -t $(syslog_tag) -m \ 178 "Validate - %s is invalid" \ 179 ${VERSION} 180 ;; 181 esac 182 183 # The application password required to start/stop the Concurrent Manager can now 184 # be stored within a restricted file instead of supplying the password when the 185 # resource is created. Later on validation will issue a warning message if the 186 # restricted file is not owned by root with read only permissions and that a 187 # password is set within ${APPS_PASSWD}. 188 189 if [ "${COMPONENT}" = "cmg" -a ${#APPS_PASSWD} -eq 0 ] 190 then 191 APPS_PASSWD=$(/usr/bin/cat /opt/SUNWscebs/.${SID}_passwd) 192 fi 193 194 # Determine the newtask project for start and stop 195 196 if [ "${METHOD}" != "probe" ] 197 then 198 if [ `/usr/bin/uname -r` != "5.8" ] 199 then 200 # Retrieve the resource project name 201 RESOURCE_PROJECT_NAME=`/usr/cluster/bin/scha_resource_get \ 202 -R ${RESOURCE} -G ${RESOURCEGROUP} -O RESOURCE_PROJECT_NAME` 203 204 if [ -z "${RESOURCE_PROJECT_NAME}" -o "${RESOURCE_PROJECT_NAME}" = "default" ] 205 then 206 # Retrieve the resource group project name 207 RESOURCE_PROJECT_NAME=`/usr/cluster/bin/scha_resourcegroup_get \ 208 -G ${RESOURCEGROUP} -O RG_PROJECT_NAME` 209 fi 210 fi 211 212 # Validate that ${APPSUSER} belongs to the ${RESOURCE_PROJECT_NAME} 213 if [ "${RESOURCE_PROJECT_NAME}" ] 214 then 215 PROJ_MEMBER=`/usr/bin/projects ${APPSUSER} | /usr/bin/egrep "^${RESOURCE_PROJECT_NAME} | ${RESOURCE_PROJECT_NAME} | ${RESOURCE_PROJECT_NAME}$|^${RESOURCE_PROJECT_NAME}$"` 216 217 if [ -z "${PROJ_MEMBER}" ] 218 then 219 scds_syslog -p daemon.notice -t $(syslog_tag) -m \ 220 "%s - The user %s does not belongs to project %s" \ 221 "${MYNAME}" "${APPSUSER}" "${RESOURCE_PROJECT_NAME}" 222 else 223 TASK_COMMAND="/usr/bin/newtask -p ${RESOURCE_PROJECT_NAME}" 224 fi 225 fi 226 fi 227 else 228 exit 1 229 fi 230 231 [ -x /sbin/zonename ] && ZONENAME=`/sbin/zonename` 232 233 set_redirection 234 235 case "${METHOD}" in 236 start) 237 validate 238 rc=$? 239 [ "${rc}" -ne 0 ] && return ${rc} 240 241 startebs ${COMPONENT} 242 rc=$? 243 ;; 244 stop) 245 if [ "${COMPONENT}" = "cmg" ] 246 then 247 248 # If the Internal Manager is lost 249 # then tidy up any loose pids 250 251 query_pids "-w CPMGR" 252 rc=$? 253 254 if [ "${rc}" -ne 0 ] 255 then 256 cleanup cmg "FND" 257 return 0 258 fi 259 fi 260 261 orderly_stop ${COMPONENT} 262 rc=$? 263 ;; 264 probe) 265 checkebs ${COMPONENT} 266 rc=$? 267 ;; 268 validate) 269 validate 270 rc=$? 271 ;; 272 esac 273 274 debug_message "Method: ${MYNAME} - End" 275 exit ${rc} 276