Print this page
| Split |
Close |
| Expand all |
| Collapse all |
--- /workspace/du105637/oscposthot/webrev/usr/src/cmd/ha-services/gds-agents/PostgreSQL/pgs_smf_register.ksh-
+++ pgs_smf_register.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 #
|
↓ open down ↓ |
13 lines elided |
↑ open up ↑ |
14 14 # When distributing Covered Code, include this CDDL HEADER in each
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
23 23 #
24 -# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
24 +# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
25 25 # Use is subject to license terms.
26 26 #
27 27
28 28 #ident "%Z%%M% %I% %E% SMI"
29 29
30 30 MYDIR=/opt/SUNWscPostgreSQL
31 31 MYFILE=
32 32 MYCONFIG=
33 33 MANIFEST_DIR=/var/svc/manifest/application/sczone-agents
34 34
35 35 MYNAME=`basename ${0}`
36 36
37 37 . ${MYDIR}/etc/config
38 38 . ${MYDIR}/lib/functions_static
39 39 . ${MYDIR}/bin/functions
40 40
41 41
42 42 #############################################################
43 43 # create_xml()
44 44 #
45 45 # This function creates the xml manifest that will get called
46 46 # by SMF, i.e. svcadm enable <service> . This allows the SMF
47 47 # service to be called in a zone by the
48 48 #
49 49 # Sun Cluster Data Service for Solaris Container
50 50 # - sczsmf component
51 51 #
52 52 #############################################################
53 53
54 54 create_xml()
55 55 {
56 56 MYDIR=$1
57 57 MYFILE=$2
58 58
|
↓ open down ↓ |
24 lines elided |
↑ open up ↑ |
59 59 if [ ! -d "${MANIFEST_DIR}" ]
60 60 then
61 61 mkdir -p ${MANIFEST_DIR}
62 62 fi
63 63
64 64 cat > ${MANIFEST_DIR}/${MYFILE}.xml <<-EOF
65 65 <?xml version="1.0"?>
66 66 <!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
67 67
68 68 <!--
69 - Copyright 2006 Sun Microsystems, Inc. All rights reserved.
69 + Copyright 2008 Sun Microsystems, Inc. All rights reserved.
70 70 Use is subject to license terms.
71 71
72 72 -->
73 73
74 74 <service_bundle type='manifest' name='${MYFILE}'>
75 75
76 76 <service
77 77 name='application/sczone-agents'
78 78 type='service'
79 79 version='1'>
80 80
|
↓ open down ↓ |
1 lines elided |
↑ open up ↑ |
81 81 <!--
82 82 Common dependencies for the service
83 83 -->
84 84
85 85 <dependency name='pgs_services'
86 86 grouping='require_all'
87 87 restart_on='none'
88 88 type='service'>
89 89 <service_fmri value='svc:/milestone/multi-user-server'/>
90 90 <service_fmri value='svc:/network/loopback'/>
91 - <service_fmri value='svc:/network/physical'/>
92 91 </dependency>
93 92
94 93 <instance name='${MYFILE}' enabled='false'>
95 94
96 95
97 96 <exec_method
98 97 type='method'
99 98 name='start'
100 99 exec='${MYDIR}/bin/control_pgs start'
101 100 timeout_seconds='300' >
102 101 <method_context project='${PROJECT}' >
103 102 <method_credential user='${USER}' />
104 103 </method_context>
105 104 </exec_method>
106 105
107 106 <exec_method
108 107 type='method'
109 108 name='stop'
110 109 exec='${MYDIR}/bin/control_pgs stop'
111 110 timeout_seconds='300' >
112 111 <method_context project='${PROJECT}' >
113 112 <method_credential user='${USER}' />
114 113 </method_context>
115 114 </exec_method>
116 115
117 116 <!--
118 117 Instance specific parameters
119 118 -->
120 119
121 120 <!--
122 121
123 122 This manifest does not restart on coredumps or abnormal process termination.
124 123 PostgreSQL has its own restart capabilities, to restart child postmaster processes.
125 124 If the parent postmaster dies, the whole process tree will disappear..
126 125 Due to this fact it is sufficient, to restart on an empty process tree and on HW error.
127 126
128 127 For additional information start with man svc.startd
129 128
130 129 -->
131 130
132 131 <property_group name='startd' type='framework'>
133 132 <propval name='ignore_error' type='astring' value='core,signal' />
134 133 </property_group>
135 134
136 135 <property_group name='parameters' type='general'>
137 136 <propval name='Resource' type='astring' value='${RS}'/>
138 137 <propval name='Resource_group' type='astring' value='${RG}'/>
139 138 <propval name='Parameter_File' type='astring' value='${PFILE}'/>
140 139 </property_group>
141 140
142 141 </instance>
143 142
144 143 <stability value='Evolving' />
145 144
146 145 <template>
147 146 <common_name>
148 147 <loctext xml:lang='C'>
149 148 Application PostgresSql
150 149 </loctext>
151 150 </common_name>
152 151 </template>
153 152 </service>
154 153
155 154 </service_bundle>
156 155
157 156 EOF
158 157 }
159 158
160 159 typeset opt
161 160
162 161 while getopts 'f:' opt
163 162 do
164 163 case "${opt}" in
165 164 f) MYCONFIG=${OPTARG};;
166 165 *) exit 1;;
167 166 esac
168 167 done
169 168
170 169 # Sourcing the specified config file, either the default one,
171 170 # or the one supplied with -f
172 171
173 172 if [ -n "${MYCONFIG}" ] && [ -f "${MYCONFIG}" ]
174 173 then
175 174 echo "sourcing ${MYCONFIG}"
176 175 . ${MYCONFIG}
177 176 else
178 177 PKGCONF=`dirname $0`/pgs_config
179 178 echo "sourcing ${PKGCONF}"
180 179 . ${PKGCONF}
181 180 fi
182 181
183 182 # checking and initializing user and project, if they are not set
184 183
185 184 if [ -z "${PROJECT}" ]
186 185 then
187 186 PROJECT=:default
188 187 fi
189 188
190 189 if [ -z "${USER}" ]
191 190 then
192 191 USER=root
193 192 fi
194 193
195 194
196 195 MYFILE=${RS}
197 196
198 197 if create_xml $MYDIR $MYFILE
199 198 then
200 199 printf "${MANIFEST_DIR}/${MYFILE}.xml successfully created\n"
201 200 else
202 201 printf "${MANIFEST_DIR}/${MYFILE}.xml failed\n"
203 202 exit 1
204 203 fi
205 204
206 205 if /usr/sbin/svccfg validate ${MANIFEST_DIR}/${MYFILE}.xml
207 206 then
208 207 printf "${MANIFEST_DIR}/${MYFILE}.xml successfully validated\n"
209 208 else
210 209 exit 1
211 210 fi
212 211
213 212 if /usr/sbin/svccfg import ${MANIFEST_DIR}/${MYFILE}.xml
214 213 then
215 214 printf "${MANIFEST_DIR}/${MYFILE}.xml successfully imported\n"
216 215 else
217 216 exit 1
218 217 fi
219 218
220 219 # create the parameter file
221 220
222 221 if create_pfile
223 222 then
224 223 echo "creation of the parameter file ${PFILE} successful"
225 224 else
226 225 echo "creation of the parameter file ${PFILE} unsuccessful"
227 226 exit 1
228 227 fi
229 228
230 229 # Validate the parameters of the Postgres Resource
231 230
232 231 if ${MYDIR}/bin/control_pgs validate svc:/application/sczone-agents:${RS}
233 232 then
234 233 echo " validation of the PostrgeSQL smf service svc:/application/sczone-agents:${RS} successful"
235 234 else
236 235 echo " validation of the PostrgeSQL smf service svc:/application/sczone-agents:${RS} failed, fix the errors and retry"
237 236 exit 1
238 237 fi
239 238
240 239 exit 0
|
↓ open down ↓ |
139 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX