Print this page
| Split |
Close |
| Expand all |
| Collapse all |
--- /workspace/du105637/oscposthot/webrev/usr/src/cmd/ha-services/gds-agents/PostgreSQL/control_pgs.ksh-
+++ control_pgs.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 -#ident "%Z%%M% %I% %E% SMI"
27 +#ident "%Z%%M% %I% %E% SMI"
28 28 #
29 29 # Method for the PostrgresSQL agents and the smf manifest
30 30 #
31 31 # This method is called by the GDS, manifest, by the optional probe script of the smf method.
32 32 #
33 33 # it is started with options and up to 2 parameters:
34 34 #
35 35 #
36 -# $1 start stop or probe
36 +# $1 start, stop, validate, check_stdby, start_ssh_agent or probe
37 37 # $2 is the smf service tag name. It is used only if the parameter $1 is probe
38 38 #
39 39
40 40 MYNAME=`basename ${0}`
41 41 MYDIR=`dirname ${0}`
42 42
43 43 . ${MYDIR}/../etc/config
44 44 . ${MYDIR}/../lib/functions_static
45 45 . ${MYDIR}/functions
46 46
47 47 debug_message "Method: ${MYNAME} ${*} - Begin"
48 48 ${SET_DEBUG}
49 49
50 50 # get the options for gds and the zsh command, amend as appropriate
51 51
52 52 while getopts 'R:G:P:' opt
53 53 do
54 54 case "${opt}" in
55 55 R) RESOURCE=${OPTARG};;
56 56 G) RESOURCEGROUP=${OPTARG};;
57 57 P) PARFILE=${OPTARG};;
58 58 *) exit 1;;
59 59 esac
60 60 done
|
↓ open down ↓ |
14 lines elided |
↑ open up ↑ |
61 61
62 62 # if no option is set ($OPTIND is 1 in this case), use the smf properties
63 63
64 64 if [ ${OPTIND} -gt 1 ]
65 65 then
66 66 shift $((${OPTIND} - 1))
67 67 else
68 68
69 69 . /lib/svc/share/smf_include.sh
70 70
71 - # Setting SMF_FMRI in case of validate and probe
71 + # Setting SMF_FMRI in case of validate and probe and check_stdby
72 72
73 73 if [ -z "${SMF_FMRI}" ]
74 74 then
75 75 SMF_FMRI=${2}
76 76 fi
77 77
78 78 # getting the necessary parameters and filling the variables usually filled
79 79 # in from options
80 80
81 81 get_fmri_parameters
82 82 fi
83 83
84 84 # set some generic variables
85 85
86 86 LOGFILE=/var/tmp/${RESOURCE}_logfile
87 87
88 88 case ${1} in
89 89 start)
90 90
91 91 # start application PostrgresSQL
|
↓ open down ↓ |
10 lines elided |
↑ open up ↑ |
92 92
93 93 # exit from start, if the options are wrong
94 94
95 95 validate_options
96 96 rc_val=${?}
97 97 if [ ${rc_val} -ne 0 ]
98 98 then
99 99 terminate ${1} ${rc_val}
100 100 fi
101 101
102 - rm ${LOGFILE} 2>/dev/null
102 + ${RM} ${LOGFILE} 2>/dev/null
103 103
104 104 # check the content of the options
105 105
106 106 if validate
107 107 then
108 108
109 109 # source the parameter file before the actual start
110 110
111 111 . ${PARFILE}
112 112
113 113 start_pgs
114 114 rc_val=${?}
115 115
116 116 if [ ${rc_val} -eq 0 ]
117 117 then
118 118 log_message notice "start_command rc<${rc_val}>"
119 119 debug_message "Method: ${MYNAME} - End (Exit 0)"
120 120 else
121 121 log_message err "start_command rc<${rc_val}>"
122 122 fi
123 123 else
124 124 debug_message "Method: ${MYNAME} - End (Exit 1)"
125 125 rc_val=1
126 126 fi;;
127 127 stop)
128 128
129 129 # stop application PostrgresSQL
130 130
131 131 # exit from stop, if the options are wrong
132 132
133 133 validate_options
134 134 rc_val=${?}
135 135 if [ ${rc_val} -ne 0 ]
136 136 then
137 137 terminate ${1} ${rc_val}
138 138 fi
139 139
140 140 # source the parameter file before the actual stop
141 141
142 142 . ${PARFILE}
143 143
144 144 stop_pgs
145 145 rc_val=${?}
146 146
147 147 if [ "${rc_val}" -eq 0 ]
148 148 then
149 149 log_message notice "stop_command rc<${rc_val}>"
150 150 else
151 151 log_message err "stop_command rc<${rc_val}>"
152 152 fi
153 153 rc_val=0;;
154 154
155 155 probe)
156 156
157 157 # probe application PostrgresSQL
158 158
159 159 # exit from probe, if the options are wrong
160 160
161 161 validate_options
162 162 rc_val=${?}
163 163 if [ ${rc_val} -ne 0 ]
164 164 then
165 165 terminate ${1} ${rc_val}
166 166 fi
167 167
168 168
169 169 # Perform a short parameter validation for the probe, if the validation
170 170 # fails the return code is taken from the return code of the
171 171 # validate_probe function.
172 172 # The parameter file is sourced in validate_probe.
173 173
174 174 validate_probe
175 175 rc_val=${?}
176 176
177 177 if [ ${rc_val} -eq 0 ]
178 178 then
179 179
180 180 # spin off a project based smf probe if necessary, do the probe with the check function otherwise
181 181
182 182 if [ "${Project}" != ":default" ] && [ -n "${SMF_FMRI}" ]
183 183 then
184 184 /usr/bin/newtask -p ${Project} ${MYDIR}/probe_smf_pgs ${SMF_FMRI}
185 185 rc_val=$?
186 186 else
187 187 check_pgs
188 188 rc_val=$?
189 189 fi
190 190 fi;;
191 191
192 192 validate)
|
↓ open down ↓ |
80 lines elided |
↑ open up ↑ |
193 193
194 194 # validate the parameters for application PostrgresSQL
195 195
196 196 validate_options
197 197 rc_val=${?}
198 198 if [ ${rc_val} -ne 0 ]
199 199 then
200 200 terminate ${1} ${rc_val}
201 201 fi
202 202
203 - rm ${LOGFILE} 2>/dev/null
204 -
205 203 if validate
206 204 then
207 205 rc_val=0
208 206 else
209 207 rc_val=1
210 208 fi;;
209 +
210 +check_stdby)
211 +
212 + # Check if the current host is configured as a PostgreSQL standby host
213 +
214 + validate_options
215 + rc_val=${?}
216 + if [ ${rc_val} -ne 0 ]
217 + then
218 + terminate ${1} ${rc_val}
219 + fi
211 220
221 + ${RM} ${LOGFILE} 2>/dev/null
222 +
223 + # check the content of the options
224 +
225 + if validate
226 + then
227 +
228 + # Source the parameter file, to get the necessary informations for
229 + # the check.
230 +
231 + . ${PARFILE}
232 +
233 + if check_stdby
234 + then
235 + rc_val=0
236 + else
237 + rc_val=1
238 + fi
239 + else
240 + rc_val=1
241 + fi;;
242 +
243 +start_ssh_agent)
244 +
245 + # start an ssh-agent and decrypt the private ssh-key.
246 +
247 + validate_options
248 + rc_val=${?}
249 + if [ ${rc_val} -ne 0 ]
250 + then
251 + terminate ${1} ${rc_val}
252 + fi
253 +
254 + ${RM} ${LOGFILE} 2>/dev/null
255 +
256 + # check the content of the options
257 +
258 + if validate
259 + then
260 +
261 + # Source the parameter file, to get the informations for the start
262 + # of the ssh-agent.
263 +
264 + . ${PARFILE}
265 +
266 + SSH_PASSPHRASE=`${CAT} /tmp/${RESOURCE}-phrase`
267 + if start_ssh_agent ${SSH_PASSPHRASE}
268 + then
269 + rc_val=0
270 + else
271 + rc_val=1
272 + fi
273 + else
274 + rc_val=1
275 + fi;;
276 +
212 277 esac
213 278
214 279 # terminate with the right return code, either with an smf specific or the gds/zsh based
215 280 # return code
216 281
217 282 debug_message "Method: ${MYNAME} ${*} - End terminating"
218 283 terminate ${1} ${rc_val}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX