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