Print this page
| Split |
Close |
| Expand all |
| Collapse all |
--- /workspace/neilga/ohacds-ids/webrev/usr/src/cmd/ha-services/gds-agents/ids/control_ids.ksh-
+++ control_ids.ksh
1 1 #!/usr/bin/ksh
2 2 #
3 3 # CDDL HEADER START
4 4 #
5 5 # The contents of this file are subject to the terms of the
6 6 # Common Development and Distribution License (the License).
7 7 # You may not use this file except in compliance with the License.
8 8 #
9 9 # You can obtain a copy of the license at usr/src/CDDL.txt
10 10 # or http://www.opensolaris.org/os/licensing.
11 11 # See the License for the specific language governing permissions
12 12 # and limitations under the License.
13 13 #
14 14 # When distributing Covered Code, include this CDDL HEADER in each
|
↓ open down ↓ |
14 lines elided |
↑ open up ↑ |
15 15 # file and include the License file at usr/src/CDDL.txt.
16 16 # If applicable, add the following below this CDDL HEADER, with the
17 17 # fields enclosed by brackets [] replaced with your own identifying
18 18 # information: Portions Copyright [yyyy] [name of copyright owner]
19 19 #
20 20 # CDDL HEADER END
21 21 #
22 22 # Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 23 # Use is subject to license terms.
24 24 #
25 -#ident "@(#)control_ids.ksh 1.2 08/02/04 SMI"
25 +#ident "@(#)control_ids.ksh 1.3 08/05/27 SMI"
26 26 #
27 27 # Usage GDS: <options> <parameter1> <parameter2>
28 28 #
29 -# Usage SMF: <parameter1> <parameter2> <parameter3>
30 -#
31 29 # <options>: -R <resource> -G <resourcegroup> etc.
32 30 # parameter1: start | stop | probe | validate
33 31 # parameter2: ids
34 -# parameter3: <FMRI>
35 32
36 -MYNAME=`/usr/bin/basename $0`
37 -MYDIR=`/usr/bin/dirname $0`
33 +MYNAME=$(/usr/bin/basename $0)
34 +MYDIR=$(/usr/bin/dirname $0)
38 35
39 36 . ${MYDIR}/../etc/config
40 37
41 38 typeset opt
42 39
43 40 while getopts 'R:G:U:D:C:S:H:' opt
44 41 do
45 42 case "${opt}" in
46 43 R) RESOURCE=${OPTARG};;
47 44 G) RESOURCEGROUP=${OPTARG};;
48 45 U) USERID=${OPTARG};;
49 46 D) INFORMIXDIR=${OPTARG};;
50 47 C) ONCONFIG=${OPTARG};;
51 48 S) INFORMIXSERVER=${OPTARG};;
52 49 H) INFORMIXSQLHOSTS=${OPTARG};;
53 50 *) exit 1;;
54 51 esac
55 52 done
56 53
57 -if [ "${OPTIND}" -gt 1 ]
58 -then
59 - # Called by GDS
60 - CALLER=GDS
54 +shift $((${OPTIND} -1))
61 55
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 56 METHOD=${1}
73 57 COMPONENT=${2}
74 58
75 -if [ "${CALLER}" = "GDS" ]
76 -then
77 - . ${MYDIR}/functions
59 +. ${MYDIR}/functions
78 60
79 - # Perform all the scha* calls
80 - TASK_COMMAND=""
61 +# Perform all the scha* calls
81 62
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
63 +TASK_COMMAND=""
87 64
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
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
93 70
94 - # Retrieve the resource project name so that we can run any
95 - # Informix commands under the specified user's project.
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
96 76
97 - RESOURCE_PROJECT_NAME=`/usr/cluster/bin/scha_resource_get \
98 - -R ${RESOURCE} -G ${RESOURCEGROUP} -O RESOURCE_PROJECT_NAME`
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)
99 82
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
83 +if [ -z "${RESOURCE_PROJECT_NAME}" -o "${RESOURCE_PROJECT_NAME}" = "default" ]
84 +then
85 + # Retrieve the resource group project name
106 86
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
87 + RESOURCE_PROJECT_NAME=$(/usr/cluster/bin/scha_resourcegroup_get \
88 + -G ${RESOURCEGROUP} -O RG_PROJECT_NAME)
89 +fi
113 90
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
91 +# Validate that ${USERID} belongs to the ${RESOURCE_PROJECT_NAME}
135 92
136 - USERID=`/usr/bin/svcprop -p start/user ${SMF_FMRI}`
137 - PROJECT=`/usr/bin/svcprop -p start/project ${SMF_FMRI}`
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
138 98
139 - . ${MYDIR}/functions
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}"
140 113 fi
141 114
142 115 debug_message "Method: ${MYNAME} - Begin"
143 116 ${SET_DEBUG}
144 117
145 -[ -x /sbin/zonename ] && ZONENAME=`/sbin/zonename`
118 +[ -x /sbin/zonename ] && ZONENAME=$(/sbin/zonename)
146 119
147 120 set_redirection
148 121
149 122 case "${METHOD}" in
150 123 start)
151 124 cleanup_ipc
152 125 start_ids
153 126 rc=$?
154 127 ;;
155 128
156 129 stop)
157 130 stop_ids
158 131 rc=0
159 132 ;;
160 133
161 134 probe)
162 135 get_state
163 136 check_ids
164 137 rc=$?
165 138 ;;
166 139 validate)
167 140 validate
168 141 rc=$?
169 142 ;;
170 143 esac
171 144
172 145 debug_message "Method: ${MYNAME} - End"
173 146 exit ${rc}
|
↓ open down ↓ |
18 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX