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 "%Z%%M% %I% %E% 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
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 ;;
166 validate)
167 validate
168 rc=$?
169 ;;
170 esac
171
172 debug_message "Method: ${MYNAME} - End"
173 exit ${rc}