Home | History | Annotate | Download | only in 9ias
      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	"@(#)control_oas.ksh	1.8	07/06/06 SMI"
     28 #
     29 # Usage GDS: <options> <parameter1> <parameter2>
     30 # 
     31 #	<options>: -R <resource> -G <resourcegroup> etc.
     32 #	parameter1: start | stop | probe
     33 #	parameter2: em | oidldap | oidmon | opmn
     34 
     35 MYNAME=`basename $0`
     36 MYDIR=`dirname $0`
     37 
     38 typeset opt
     39 
     40 while getopts 'R:G:O:S:H:U:P:E:D:C:' opt
     41 do
     42 	case "${opt}" in
     43 		R)      RESOURCE=${OPTARG};;
     44 		G)      RESOURCEGROUP=${OPTARG};;
     45 		O)      OIAS_ORAHOME=${OPTARG};;
     46 		S)      OIAS_ORASID=${OPTARG};;
     47 		H)      OIAS_LHOST=${OPTARG};;
     48 		U)      OIAS_USER=${OPTARG};;
     49 		P)      OIAS_ADMIN=${OPTARG};;
     50 		E)      OIAS_INFRA=${OPTARG};;
     51 		D)      OIAS_FQDN=${OPTARG};;
     52 		C)      OIAS_OPMN=${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 	exit 1
     66 fi
     67 
     68 METHOD=${1}
     69 COMPONENT=${2}
     70 
     71 . ${MYDIR}/../etc/config
     72 . ${MYDIR}/functions
     73 
     74 debug_message "Method: ${MYNAME} - Begin"
     75 ${SET_DEBUG}
     76 
     77 if [ "${CALLER}" = "GDS" ]
     78 then
     79 	# Determine the newtask project for start and stop
     80 
     81 	TASK_COMMAND=""
     82 
     83 	if [ "${METHOD}" != "probe" ]
     84 	then
     85 	   if [ `/usr/bin/uname -r` != "5.8" ]
     86 	   then
     87 	      # Retrieve the resource project name
     88 	      RESOURCE_PROJECT_NAME=`/usr/cluster/bin/scha_resource_get \
     89 		-R ${RESOURCE} -G ${RESOURCEGROUP} -O RESOURCE_PROJECT_NAME`
     90 		
     91 	      if [ -z "${RESOURCE_PROJECT_NAME}" -o "${RESOURCE_PROJECT_NAME}" = "default" ]
     92 	      then
     93 		# Retrieve the resource group project name 
     94 		RESOURCE_PROJECT_NAME=`/usr/cluster/bin/scha_resourcegroup_get \
     95 		   -G ${RESOURCEGROUP} -O RG_PROJECT_NAME`
     96 	      fi	
     97 	   fi
     98 
     99 	   # Validate that ${OIAS_USER} belongs to the ${RESOURCE_PROJECT_NAME}
    100 	   if [ "${RESOURCE_PROJECT_NAME}" ]
    101 	   then
    102 	      PROJ_MEMBER=`/usr/bin/projects ${OIAS_USER} | /usr/bin/egrep "^${RESOURCE_PROJECT_NAME} | ${RESOURCE_PROJECT_NAME} | ${RESOURCE_PROJECT_NAME}$|^${RESOURCE_PROJECT_NAME}$"`
    103 
    104 	      if [ -z "${PROJ_MEMBER}" ]
    105 	      then
    106 		# SCMSGS
    107 		# @explanation
    108 		# The specified user does not belong to the project defined by
    109 		# Resource_project_name or Rg_project_name.
    110 		# @user_action
    111 		# Add the user to the defined project in /etc/project.
    112 		scds_syslog -p daemon.notice -t $(syslog_tag) -m \
    113 		   "%s - The user %s does not belongs to project %s" \
    114 		   "${MYNAME}" "${APPSUSER}" "${RESOURCE_PROJECT_NAME}"
    115 	      else
    116 		TASK_COMMAND="/usr/bin/newtask -p ${RESOURCE_PROJECT_NAME}"
    117 	      fi
    118 	   fi
    119 	fi
    120 else
    121 	exit 1
    122 fi
    123 
    124 [ -x /sbin/zonename ] && ZONENAME=`/sbin/zonename`
    125 [ "${COMPONENT}" = "oidldap" ] && COMPONENT=oidldapd
    126 
    127 set_redirection
    128 
    129 case "${METHOD}" in
    130 	start)
    131 		validate
    132 		rc=$?
    133 		[ "${rc}" -ne 0 ] && return ${rc}
    134 
    135 		# For opmn, if we're running v9.0.2 or v9.0.3 then
    136 		# we need to to reset the password and reregister
    137 		# before starting opmn
    138 
    139 		if [ "${COMPONENT}" = "opmn" ]
    140 		then
    141 		   check_ias_version
    142 
    143 		   if [ "${rc_check_ias_version}" -eq 1 ]
    144 		   then
    145 			/usr/bin/sleep 300 &
    146 			/usr/cluster/bin/pmfadm -s ${RESOURCEGROUP},${RESOURCE},0.svc
    147 
    148 			resetiAS_passwd
    149 		
    150 			reregister
    151 		   fi
    152 		fi
    153 
    154 		execute_${COMPONENT} start
    155 
    156 		rc=$?
    157 		;;
    158 	stop)
    159 		if [ "${COMPONENT}" = "opmn" ]
    160 		then
    161 		   execute_${COMPONENT} stopall
    162 		else
    163 		   execute_${COMPONENT} stop
    164 		fi
    165 
    166 		rc=$?
    167 		;;
    168 	probe)
    169 		check_${COMPONENT}
    170 
    171 		rc=$?
    172 		;;
    173 esac
    174 
    175 debug_message "Method: ${MYNAME} - End"
    176 exit ${rc}
    177