Repository navigation
Expand file tree
/
Copy pathtesting.sh
More file actions
111 lines (93 loc) · 2.81 KB
/
Copy pathtesting.sh
File metadata and controls
111 lines (93 loc) · 2.81 KB
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
#!/bin/bash
set -x
environment=$1
user=`whoami`
##################################################
# Print the Usage of the script and exit ##
##################################################
function usage {
echo "No arguments provided OR insufficient arguments passed. "
echo "USAGE: ./gw_cleanup.sh <application name> <environment name> "
echo "environment name: One of dev01, dev02, gw_dev, gw_prj, gw_dev4, qa, qa2, gw_qa, stg, stg2, stg3, gw_stg_A, gw_stg_B, ,gw_iwv_stg, gw_iwv_prd, perf, gw_perf_B, prd, gw_prd_A, gw_prd_B"
echo "application name : api, gw"
echo "example: ./gw_cleanup.sh api dev01 "
echo "example: ./gw_cleanup.sh gw gw_dev "
exit 1
}
##################################
# Input variables ##
##################################
argc=$#
##################################################
#check if variable is passed or not. ##
# PW - Moving to top. We must have at least an ##
# environment variable. ##
##################################################
if [ $argc -eq 1 -o $argc -gt 2 ]; then
usage
exit
fi
#TOMAIL="status@clnxbcmon11.hilton.com"
#TOMAIL="ravishankar.aithala.contractor@hilton.com"
TOMAIL="WebsiteTechArch@hilton.com"
#CCMAIL="hiltonserveradmin@hilton.com"
START_TIME=`date +%H:%M:%S`
function send_email_success
{
END_TIME=`date +%H:%M:%S`
/usr/lib/sendmail -t << EOF
To: $TOMAIL
From: HiltonServerAdmin <hiltonserveradmin@hilton.com>
Subject: Success|$application|$environment| Cleanup|`hostname`
========================================
OUTPUT LOG
========================================
`echo "Job: cleanup.sh"`
`echo "Start: $START_TIME"`
`echo "End: $END_TIME"`
`echo "cleanup have been cleaned successfully "`
`cat $log_file`
EOF
}
function send_email_failure
{
END_TIME=`date +%H:%M:%S`
/usr/lib/sendmail -t << EOF
To: $TOMAIL
Cc: $CCMAIL
From: HiltonServerAdmin <hiltonserveradmin@hilton.com>
Subject: FAILED|$application|$environment| Cleanup|`hostname`
========================================
OUTPUT LOG
========================================
`echo "Job: cleanup.sh"`
`echo "Start: $START_TIME"`
`echo "End: $END_TIME"`
`echo "Error in cleaning $environment $application : Please check the logs "`
EOF
}
dev01 () {
output=`ls -l /appsnfs/hms/$environment/deployment/$application`
deployed_hmsapp_version_no=`echo $output|cut -d'-' -f3`
deployed_hmsstatic_version_no=`ls -l /appsnfs/hms/dev01/deployment/hmstatic | cut -d'-' -f3`
}
generic () {
}
returnvalue () {
if [ $rtn1 -ne 0 ] || [ $rtn2 -ne 0 ]|| [ $rtn3 -ne 0 ] || [ $rtn4 -ne 0 ]|| [ $rtn5 -ne 0 ] || [ $rtn6 -ne 0 ]|| [ $rtn7 -ne 0 ]
then
send_email_failure
else
send_email_success
fi
}
case $enviornment in
dev01) dev01
returnvalue
;;
dev02) generic
returnvalue
;;
*) Usage
;;
esac