Sdiff control_ids.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 "@(#)control_ids.ksh 1.2 08/02/04 SMI" 26 # 27 # Usage GDS: <options> <parameter1> <parameter2> 28 # 29 # Usage SMF: <parameter1> <parameter2> <parameter3> 30 # 31 # <options>: -R <resource> -G <resourcegroup> etc. 32 # parameter1: start | stop | probe | validate 33 # parameter2: ids 34 # parameter3: <FMRI> 35 36 MYNAME=`/usr/bin/basename $0` 37 MYDIR=`/usr/bin/dirname $0` 38 39 . ${MYDIR}/../etc/config 40 41 typeset opt 42 43 while getopts 'R:G:U:D:C:S:H:' opt 44 do 45 case "${opt}" in 46 R) RESOURCE=${OPTARG};; 47 G) RESOURCEGROUP=${OPTARG};; 48 U) USERID=${OPTARG};; 49 D) INFORMIXDIR=${OPTARG};; 50 C) ONCONFIG=${OPTARG};; 51 S) INFORMIXSERVER=${OPTARG};; 52 H) INFORMIXSQLHOSTS=${OPTARG};; 53 *) exit 1;; 54 esac 55 done 56 57 if [ "${OPTIND}" -gt 1 ] 58 then 59 # Called by GDS 60 CALLER=GDS 61 62 shift $((${OPTIND} -1)) 63 else 64 # Called by SMF 65 CALLER=SMF 66 67 . /lib/svc/share/smf_include.sh 68 69 SMF_FMRI=${3} 70 fi 71 72 METHOD=${1} 73 COMPONENT=${2} 74 75 if [ "${CALLER}" = "GDS" ] 76 then 77 . ${MYDIR}/functions 78 79 # Perform all the scha* calls 80 TASK_COMMAND="" 81 82 if [ "${METHOD}" = "start" ] 83 then 84 START_TIMEOUT=`/usr/cluster/bin/scha_resource_get -O START_TIMEOUT \ 85 -R ${RESOURCE} -G ${RESOURCEGROUP} ` 86 fi 87 88 if [ "${METHOD}" = "stop" ] 89 then 90 STOP_TIMEOUT=`/usr/cluster/bin/scha_resource_get -O STOP_TIMEOUT \ 91 -R ${RESOURCE} -G ${RESOURCEGROUP} ` 92 fi 93 94 # Retrieve the resource project name so that we can run any 95 # Informix commands under the specified user's project. 96 97 RESOURCE_PROJECT_NAME=`/usr/cluster/bin/scha_resource_get \ 98 -R ${RESOURCE} -G ${RESOURCEGROUP} -O RESOURCE_PROJECT_NAME` 99 100 if [ -z "${RESOURCE_PROJECT_NAME}" -o "${RESOURCE_PROJECT_NAME}" = "default" ] 101 then 102 # Retrieve the resource group project name 103 RESOURCE_PROJECT_NAME=`/usr/cluster/bin/scha_resourcegroup_get \ 104 -G ${RESOURCEGROUP} -O RG_PROJECT_NAME` 105 fi 106 107 # Validate that ${USERID} belongs to the ${RESOURCE_PROJECT_NAME} 108 if [ -n "${RESOURCE_PROJECT_NAME}" ] 109 then 110 PROJ_MEMBER=`/usr/bin/projects ${USERID} | /usr/bin/egrep "^${RESOURCE_PROJECT_NAME} | \ 111 ${RESOURCE_PROJECT_NAME} | ${RESOURCE_PROJECT_NAME}$|^${RESOURCE_PROJECT_NAME}$"` 112 fi 113 114 if [ -z "${PROJ_MEMBER}" ] 115 then 116 # SCMSGS 117 # @explanation 118 # The userid does not belong to the specified project. 119 # @user_action 120 # Ensure the userid exists within the project. Check that 121 # you have the correct userid and project name. 122 scds_syslog -p daemon.notice -t $(syslog_tag) -m \ 123 "%s - The user %s does not belong to project %s" \ 124 "${MYNAME}" "${USERID}" "${RESOURCE_PROJECT_NAME}" 125 return 1 126 else 127 TASK_COMMAND="/usr/bin/newtask -p ${RESOURCE_PROJECT_NAME}" 128 fi 129 else 130 for i in RESOURCE RESOURCEGROUP INFORMIXDIR ONCONFIG INFORMIXSERVER \ 131 INFORMIXSQLHOSTS START_TIMEOUT STOP_TIMEOUT 132 do 133 export $i=`/usr/bin/svcprop -p parameters/$i ${SMF_FMRI}` 134 done 135 136 USERID=`/usr/bin/svcprop -p start/user ${SMF_FMRI}` 137 PROJECT=`/usr/bin/svcprop -p start/project ${SMF_FMRI}` 138 139 . ${MYDIR}/functions 140 fi 141 142 debug_message "Method: ${MYNAME} - Begin" 143 ${SET_DEBUG} 144 145 [ -x /sbin/zonename ] && ZONENAME=`/sbin/zonename` 146 147 set_redirection 148 149 case "${METHOD}" in 150 start) 151 cleanup_ipc 152 start_ids 153 rc=$? 154 ;; 155 156 stop) 157 stop_ids 158 rc=0 159 ;; 160 161 probe) 162 get_state 163 check_ids 164 rc=$? 165 ;;


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 "@(#)control_ids.ksh 1.3 08/05/27 SMI" 26 # 27 # Usage GDS: <options> <parameter1> <parameter2> 28 # 29 # <options>: -R <resource> -G <resourcegroup> etc. 30 # parameter1: start | stop | probe | validate 31 # parameter2: ids 32 33 MYNAME=$(/usr/bin/basename $0) 34 MYDIR=$(/usr/bin/dirname $0) 35 36 . ${MYDIR}/../etc/config 37 38 typeset opt 39 40 while getopts 'R:G:U:D:C:S:H:' opt 41 do 42 case "${opt}" in 43 R) RESOURCE=${OPTARG};; 44 G) RESOURCEGROUP=${OPTARG};; 45 U) USERID=${OPTARG};; 46 D) INFORMIXDIR=${OPTARG};; 47 C) ONCONFIG=${OPTARG};; 48 S) INFORMIXSERVER=${OPTARG};; 49 H) INFORMIXSQLHOSTS=${OPTARG};; 50 *) exit 1;; 51 esac 52 done 53 54 shift $((${OPTIND} -1)) 55 56 METHOD=${1} 57 COMPONENT=${2} 58 59 . ${MYDIR}/functions 60 61 # Perform all the scha* calls 62 63 TASK_COMMAND="" 64 65 if [ "${METHOD}" = "start" ] 66 then 67 START_TIMEOUT=$(/usr/cluster/bin/scha_resource_get -O START_TIMEOUT \ 68 -R ${RESOURCE} -G ${RESOURCEGROUP} ) 69 fi 70 71 if [ "${METHOD}" = "stop" ] 72 then 73 STOP_TIMEOUT=$(/usr/cluster/bin/scha_resource_get -O STOP_TIMEOUT \ 74 -R ${RESOURCE} -G ${RESOURCEGROUP} ) 75 fi 76 77 # Retrieve the resource project name so that we can run any 78 # Informix commands under the specified user's project. 79 80 RESOURCE_PROJECT_NAME=$(/usr/cluster/bin/scha_resource_get \ 81 -R ${RESOURCE} -G ${RESOURCEGROUP} -O RESOURCE_PROJECT_NAME) 82 83 if [ -z "${RESOURCE_PROJECT_NAME}" -o "${RESOURCE_PROJECT_NAME}" = "default" ] 84 then 85 # Retrieve the resource group project name 86 87 RESOURCE_PROJECT_NAME=$(/usr/cluster/bin/scha_resourcegroup_get \ 88 -G ${RESOURCEGROUP} -O RG_PROJECT_NAME) 89 fi 90 91 # Validate that ${USERID} belongs to the ${RESOURCE_PROJECT_NAME} 92 93 if [ -n "${RESOURCE_PROJECT_NAME}" ] 94 then 95 PROJ_MEMBER=$(/usr/bin/projects ${USERID} | /usr/bin/egrep "^${RESOURCE_PROJECT_NAME} | \ 96 ${RESOURCE_PROJECT_NAME} | ${RESOURCE_PROJECT_NAME}$|^${RESOURCE_PROJECT_NAME}$") 97 fi 98 99 if [ -z "${PROJ_MEMBER}" ] 100 then 101 # SCMSGS 102 # @explanation 103 # The userid does not belong to the specified project. 104 # @user_action 105 # Ensure the userid exists within the project. Check that 106 # you have the correct userid and project name. 107 scds_syslog -p daemon.notice -t $(syslog_tag) -m \ 108 "%s - The user %s does not belong to project %s" \ 109 "${MYNAME}" "${USERID}" "${RESOURCE_PROJECT_NAME}" 110 return 1 111 else 112 TASK_COMMAND="/usr/bin/newtask -p ${RESOURCE_PROJECT_NAME}" 113 fi 114 115 debug_message "Method: ${MYNAME} - Begin" 116 ${SET_DEBUG} 117 118 [ -x /sbin/zonename ] && ZONENAME=$(/sbin/zonename) 119 120 set_redirection 121 122 case "${METHOD}" in 123 start) 124 cleanup_ipc 125 start_ids 126 rc=$? 127 ;; 128 129 stop) 130 stop_ids 131 rc=0 132 ;; 133 134 probe) 135 get_state 136 check_ids 137 rc=$? 138 ;;