Home | History | Annotate | Download | only in ids
      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 # 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 		;;
    139 	validate)
    140 		validate
    141 		rc=$?
    142 		;;
    143 esac
    144 
    145 debug_message "Method: ${MYNAME} - End"
    146 exit ${rc}
    147