-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy path3050_target_apps_processing.sh
409 lines (408 loc) · 16.1 KB
/
3050_target_apps_processing.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
#!/bin/bash
#
#####################################################################################################
# S T A G I N G O V E R L A Y - target Apps Tasks #
# 3050_target_apps_processing.sh #
#####################################################################################################
#
# Import properties file
#
. clone_environment.properties
#################################################
# Default Configuration #
#################################################
trgbasepath="${basepath}targets/"
logfilepath="${basepath}logs/"
functionbasepath="${basepath}function_lib/"
custfunctionbasepath="${basepath}custom_lib/"
custsqlbasepath="${custfunctionbasepath}sql/"
sqlbasepath="${functionbasepath}sql/"
rmanbasepath="${functionbasepath}rman/"
abendfile="$trgbasepath""$trgappname"/"$trgappname"_3050_abend_step"$2"
logfilename="$trgdbname"_Overlay_Apps_PART2$(date +%a)"_$(date +%F).log"
####################################################################################################
# add functions library #
####################################################################################################
. ${functionbasepath}/usage.sh
. ${functionbasepath}/syncpoint.sh
. ${functionbasepath}/send_notification.sh
. ${functionbasepath}/os_tar_gz_file.sh
. ${functionbasepath}/os_untar_gz_file.sh
. ${functionbasepath}/os_delete_move_file.sh
. ${functionbasepath}/os_delete_move_dir.sh
. ${functionbasepath}/os_user_check.sh
. ${functionbasepath}/os_verify_or_make_directory.sh
. ${functionbasepath}/os_verify_or_make_file.sh
. ${functionbasepath}/is_os_file_exist.sh
. ${functionbasepath}/is_os_dir_exist.sh
. ${functionbasepath}/is_os_process_running.sh
. ${functionbasepath}/os_kill_process_homepath.sh
. ${functionbasepath}/apps_run_adcfgclone.sh
. ${functionbasepath}/apps_run_autoconfig.sh
. ${functionbasepath}/error_notification_exit.sh
. ${functionbasepath}/custom_sql_run.sh
. ${functionbasepath}/get_decrypted_password.sh
. ${functionbasepath}/appschangepassword.sh
. ${custfunctionbasepath}/appspostclonesteps$trgappname.sh
#
########################################
# VALIDATIONS #
########################################
#
if [ $# -lt 3 ]
then
echo " ====> Abort!!!. Invalid apps arguments for overlay"
usage $0 :3050_target_apps_processing "[APPS NAME] [TIER NO 1..3] Y/N/C(paratial[N] / full[Y] / conig only(C)/ start only(S))"
########################################################################
# send notification and exit #
########################################################################
send_notification "$trgappname"_Overlay_abend "Invalid arguments for replication" ${TOADDR} ${RTNADDR} ${CCADDR}
exit 3
fi
#
unset tier
tier=$2
unset clonetype
clonetype=$3
#
# Check user
#
os_user_check ${appsosuser}
rcode=$?
if [ "$rcode" -gt 0 ]
then
error_notification_exit $rcode "Wrong os user, user should be ${appsosuser}!!" $trgappname 0 $LINENO
fi
#
# Validate Directory
#
os_verify_or_make_directory ${logfilepath}
os_verify_or_make_directory ${trgbasepath}
os_verify_or_make_directory ${trgbasepath}${srcappname}
os_verify_or_make_file ${abendfile} 0
if [[ ! -n "${context_file+1}" || -z "${context_file}" ]]
then
echo "CONTEXT_FILE cannot be empty, please set the environment correctly"
error_notification_exit $rcode "Validation Error: CONTEXT_FILE variable cannot be empty !!" $trgappname 0 $LINENO
fi
#
# Verify Apps environment
#
if [[ -n "${TWO_TASK+1}" && $TWO_TASK == $trgappname ]]
then
echo "Environment is correct!"
else
echo "Environment is not set or wrong environment to clone."
error_notification_exit $rcode "Wrong Enviornment to clone $trgappname !!" $trgappname 0 $LINENO
fi
trgappspwd=$( get_decrypted_password $trgappspwd )
srcappspwd=$( get_decrypted_password $srcappspwd )
srcwlsadminpwd=$( get_decrypted_password $srcwlsadminpwd )
trgdbsystem=$( get_decrypted_password $trgdbsystem )
trgappsysadmin=$( get_decrypted_password $trgappsysadmin )
trgwlsadminpwd=$( get_decrypted_password $trgwlsadminpwd )
############################################################
restart=false
while read val1 val2
do
stepnum=$val1
linenum=$val2
if [[ "$stepnum" != "0" ]]
then
restart=true
echo ""
echo " RESTART LOCATION: "$stepnum" ,around line: "$linenum""
echo " SCRIPT LOCATION: ${basepath}$0"
echo "TASK LOG LOCATION: ${trgbasepath}${trgdbname}/"
echo " RUN LOG LOCATION: ${logfilepath}"
echo ""
else
echo ""
echo " NORMAL LOCATION: "$stepnum" ,line: "$linenum""
echo " SCRIPT LOCATION: ${basepath}$0"
echo "TASK LOG LOCATION: ${trgbasepath}${trgdbname}/"
echo " RUN LOG LOCATION: ${logfilepath}"
echo ""
stepnum=`expr $stepnum + 50`
fi
done < "$abendfile"
#
now=$(date "+%m/%d/%y %H:%M:%S")
echo $now >>$logfilepath$logfilename
#
now=$(date "+%m/%d/%y %H:%M:%S")" ====> ######## $srcappname to $trgappname overlay has been started - PART3 ########"
echo $now >>$logfilepath$logfilename
#
#for step in $(seq "$stepnum" 50 650)
for (( step="$stepnum" ; step<=650; step+=50 ))
do
case $step in
"50")
#####################################################################################
# send notification that APPS overlay started #
# #
#####################################################################################
echo "START TASK: $step send_notification"
send_notification "$trgappname"_clone_started "$trgappname cloning started" ${TOADDR} ${RTNADDR} ${CCADDR}
#
########################################
# write an audit record in the log #
########################################
now=$(date "+%m/%d/%y %H:%M:%S")" ====> Send start $srcappname apps backup Notification"
echo $now >>$logfilepath$logfilename
#
echo "END TASK: $step send_notification"
;;
"100")
########################################
# check source apps status #
########################################
echo "START TASK: $step apps status check"
if is_os_process_running ${apptargethomepath}
then
echo " apps process is running.."
echo " shutting down apps.."
. ${apptargethomepath}/EBSapps.env run
{echo "apps"; echo ${trgappspwd}; echo ${trgwlsadminpwd}; } | $ADMIN_SCRIPTS_HOME/adstpall.sh @ -nopromptmsg >$logfilepath$trgappname_adstpall.log 2>&1
sleep 50
if is_os_process_running ${apptargethomepath}
then
echo " some of the apps process is still running.."
echo " killing.."
os_kill_process_homepath ${apptargethomepath} >$logfilepath$trgappname_os_kill_process.log 2>&1
sleep 20
echo " Verifying whether any process still running.."
os_kill_process_homepath ${apptargethomepath} >$logfilepath$trgappname_os_kill_process.log 2>&1
sleep 20
else
echo " apps process is not running.."
fi
fi
_step=$step
if [[ -n "${clonetype+1}" && ${clonetype} == 'Y' ]]
then
echo "~~~~ INFO: Doing full clone"
elif [[ -n "${clonetype+1}" && ${clonetype} == 'N' ]]
then
echo "~~~~ INFO: Doing partial clone"
step=200 # Equivalent to step 250
elif [[ -n "${clonetype+1}" && ${clonetype} == 'C' ]]
then
echo "~~~~ INFO: Config full clone, it will not start the apps process or run post steps"
elif [[ -n "${clonetype+1}" && ${clonetype} == 'S' ]]
then
echo "~~~~ INFO: Start apps services only, it will skip all steps and only start apps steps and perform any post steps"
step=400 # Equivalent to step 450 (start Apps services)
else
echo "~~~~ WARN: argument suppose to be Y or N, so by default it will do full clone"
fi
echo "END TASK: $_step apps status check"
;;
"150")
########################################
# Clean old apps home #
########################################
echo "START TASK: $step delete_appl_tech_st"
now=$(date "+%m/%d/%y %H:%M:%S")" ====> Delete EBSapps FMW_Home of $trgappname "
echo $now >>$logfilepath$logfilename
#
if ! is_os_file_exist ${appsourcebkupdir}${srcappname}${tier}.tar.gz
then
error_notification_exit $rcode "Apps restore is failed due to missing tar backups." $trgappname $step $LINENO
fi
if is_os_dir_exist ${apptargethomepath}/EBSapps && is_os_dir_exist ${apptargethomepath}/FMW_Home
then
echo " deleting EBSapps and FMW_Home.."
os_delete_move_dir D "${apptargethomepath}/EBSapps ${apptargethomepath}/FMW_Home"
os_delete_move_dir D "${apptargetpatchpath}/EBSapps ${apptargetpatchpath}/FMW_Home"
else
error_notification_exit $rcode "old EBSapps and old FMW_Home directory may not exist." $trgappname $step $LINENO
fi
#
rcode=$?
if [ "$rcode" -gt 0 ]
then
error_notification_exit $rcode "Deleting old apps directories was FAILED due to error!!" $trgappname $step $LINENO
fi
echo "END TASK: $step delete_appl_tech_st"
;;
"200")
########################################
# restore apps from backup #
########################################
echo "START TASK: $step os_untar_gz_file"
now=$(date "+%m/%d/%y %H:%M:%S")" ====> Untar $srcappname from backups"
echo $now >>$logfilepath$logfilename
#
if is_os_file_exist ${appsourcebkupdir}${srcappname}${tier}.tar.gz
then
echo " restoring ${appsourcebkupdir}${srcappname}${tier}.tar.gz.."
os_untar_gz_file ${appsourcebkupdir}${srcappname}${tier}.tar.gz ${apptargethomepath}
else
error_notification_exit $rcode "Apps restore is failed due to missing tar backups." $trgappname $step $LINENO
fi
#
rcode=$?
if [ "$rcode" -gt 0 ]
then
error_notification_exit $rcode "Apps restore from backups is FAILED due to error!!" $trgappname $step $LINENO
fi
echo "END TASK: $step os_untar_gz_file"
;;
"250")
#########################################
# Run adcfgclone #
#########################################
echo "START TASK: $step apps_run_adcfgclone"
now=$(date "+%m/%d/%y %H:%M:%S")" ====> Start $srcappname clone to $trgappname."
echo $now >>$logfilepath$logfilename
#
echo " application cloning to $trgappname.."
if [ "${tier}" -eq 1 ]
then
{ echo "apps"; echo ${srcappspwd}; echo ${trgwlsadminpwd}; } | apps_run_adcfgclone "${apptargethomepath}/EBSapps/comn/clone/bin" ${context_file} dualfs
rcode=$?
else
apps_run_adcfgclone "${apptargethomepath}EBSapps/comn/clone/bin" ${context_file} ${trgappspwd}
rcode=$?
fi
if [ "$rcode" -ne 0 ]
then
error_notification_exit $rcode "Apps clone for $trgappname FAILED during adcfgclone step!!" $trgappname $step $LINENO
fi
echo "END TASK: $step apps_run_adcfgclone"
;;
"300")
########################################
# Set new apps environment #
########################################
echo "START TASK: $step set apps environment"
now=$(date "+%m/%d/%y %H:%M:%S")" ====> Set apps enviroment."
echo $now >>$logfilepath$logfilename
#
echo " setting apps environment for $trgappname.."
. ${apptargethomepath}/EBSapps.env run
rcode=$?
if [ "$rcode" -ne 0 ]
then
error_notification_exit $rcode "Set Apps enviornment FAILED due to invalid environment files!!" $trgappname $step $LINENO
fi
echo "END TASK: $step set apps environment"
;;
"350")
########################################
# Change FND Users password #
########################################
echo "START TASK: $step Change FND Users passwords only when run on TIER 1"
now=$(date "+%m/%d/%y %H:%M:%S")" ====> Change FND Users passwords."
echo $now >>$logfilepath$logfilename
#
if [ "${tier}" -eq 1 ]
then
echo " changing FND Users passwords for $trgappname.."
appschangepassword ${srcappspwd} ${trgdbsystem} ${trgappsysadmin} ${trgappspwd}
rcode=$?
if [ "$rcode" -ne 0 ]
then
error_notification_exit $rcode "Change FND Users passwords FAILED!!" $trgappname $step $LINENO
fi
else
echo "~~~ Skipping this step as it is not TIER 1"
fi
echo "END TASK: $step Change FND Users passwords"
;;
"400")
########################################
# Run Autoconfig #
########################################
echo "START TASK: $step run auto config"
now=$(date "+%m/%d/%y %H:%M:%S")" ====> Run Apps AutoConfig."
echo $now >>$logfilepath$logfilename
#
echo " running apps autoconfig on $trgappname.."
apps_run_autoconfig $ADMIN_SCRIPTS_HOME ${trgappspwd}
rcode=$?
if [ "$rcode" -ne 0 ]
then
error_notification_exit $rcode "Run AutoConfig on $trgappname FAILED!!" $trgappname $step $LINENO
fi
if [[ -n "${clonetype+1}" && ${clonetype} == 'C' ]]
then
echo "~~~~ INFO: Skipping Starting Apps process and post clone steps"
step=550 # Equivalent to step 600
fi
echo "END TASK: $step run auto config"
;;
"450")
echo "Existing for Manual steps before Apps "
exit 450
########################################
# Start Apps #
########################################
echo "START TASK: $step Start Apps process"
now=$(date "+%m/%d/%y %H:%M:%S")" ====> Start Apps Process."
echo $now >>$logfilepath$logfilename
#
echo " starting apps on $trgappname.."
{echo "apps"; echo ${trgappspwd}; echo ${trgwlsadminpwd} } | $ADMIN_SCRIPTS_HOME/adstrtal.sh >$logfilepath$trgappname_adstrtal.log 2>&1
rcode=$?
if [ "$rcode" -ne 0 ]
then
error_notification_exit $rcode "Starting apps process on $trgappname FAILED!!" $trgappname $step $LINENO
fi
echo "END TASK: $step Start Apps process"
;;
# "500")
########################################
# Profile change #
########################################
# echo "START TASK: $step Change profile properties"
# now=$(date "+%m/%d/%y %H:%M:%S")" ====> Change profile properties."
# echo $now >>$logfilepath$logfilename
# #
# echo start apps on $trgappname
# custom_sql_run "" $ORACLE_HOME $trgappname "apps" ${trgappspwd} ${sqlbasepath}/apps_profile_set_sitename.sql ${sitename}
# custom_sql_run "" $ORACLE_HOME $trgappname "apps" ${trgappspwd} ${sqlbasepath}/apps_profile_set_javacolorscheme.sql ${fnd_color_scheme}
# rcode=$?
# if [ "$rcode" -ne 0 ]
# then
# error_notification_exit $rcode "Changing apps profile properties on $trgappname FAILED!!" $trgappname $step $LINENO
# fi
# echo "END TASK: $step Change profile properties"
# ;;
"550")
########################################
# Custom Post Clone steps #
########################################
echo "START TASK: $step Start post clone process"
now=$(date "+%m/%d/%y %H:%M:%S")" ====> Post clone steps."
echo $now >>$logfilepath$logfilename
#
echo " executing post clone steps on $trgappname.."
appspostclonesteps
rcode=$?
if [ "$rcode" -ne 0 ]
then
error_notification_exit $rcode "Post clone steps on $trgappname FAILED!!" $trgappname $step $LINENO
fi
echo "END TASK: $step post clone process"
;;
"600")
echo "START TASK: " $step "send_notification"
########################################################################
# send notification that target apps overlay has been completed #
########################################################################
send_notification "$trgappname Apps Overlay completed" "$trgappname overlay has been completed" ${TOADDR} ${RTNADDR} ${CCADDR}
#
echo "END TASK: " $step "send_notification"
;;
"650")
echo "START TASK: $step end-of $srcappname app backup"
syncpoint $srcappname "0 " "$LINENO"
echo "END TASK: $step end-of $srcappname app clone"
;;
*)
echo "step not found - step: $step around Line ===> " "$LINENO"
;;
esac
done