-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_war.sh
117 lines (106 loc) · 3.57 KB
/
create_war.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
#/bin/sh
#stopping tomcat
TOMCAT_DIRECTORY_PATH=/usr/local/tomcat #need to be changed
CARDEKHO_PROJECT_DIRECTORY_PATH=/media/disk1/CarDekho/ecarsinfo/trunk #need to be changed
BACKUP_DIRECTORY_PATH=/media/disk1/car_backups #need to be changed
U=`who am i | awk '{print $1}'`
cd $CARDEKHO_PROJECT_DIRECTORY_PATH
echo "getting update from svn head"
RESULT=`svn up` | grep applicationContext.xml
if [ -z "$RESULT" ]; then
echo "file applicationContext.xml is unchanged .."
FLAG=0
else
echo "file applicationContext.xml is changed(updated) .."
FLAG=1
fi
echo "Stopping Tomcat"
PID=`ps aux | grep tomcat | awk '{print $2}'`
L=`echo $PID | awk '{print NF}'`
if test $L -gt 1 ; then
`echo $PID | awk '{for(i=1; i<NF; i++) print $i}' | xargs kill -9`;
fi
if test $? -eq 0 ; then
echo "Stopped the tomcat";
else
echo "Exiting, tomcat was NOT Stopped";
fi
sleep 3
echo "runnig command Ant in directory: "pwd
ant > /dev/null
if test $? -eq 0 ; then
echo "Ant successfull";
else
echo "Exiting, ANT was NOT successfull";
exit 1;
fi
cd ..
echo "running command Ant ExportForJar on CarDekho"
ant exportforjar > /dev/null
if test $? -eq 0 ; then
echo "Ant ExportForJar successfull";
else
echo "Exiting, Ant ExportForJar was NOT successfull";
exit 1;
fi
echo "backup created then car move tomcat folder and changes in some files"
NOW=$(date +"%m-%d-%Y:%I%p")
echo "create backup folder name:-"$NOW
`rm -rf $BACKUP_DIRECTORY_PATH/$NOW`
mkdir $BACKUP_DIRECTORY_PATH/$NOW
chmod -R 777 $BACKUP_DIRECTORY_PATH/$NOW
echo "backup car"
mv $TOMCAT_DIRECTORY_PATH/webapps/car $BACKUP_DIRECTORY_PATH/$NOW
echo "copy war file desktop "
`cp $CARDEKHO_PROJECT_DIRECTORY_PATH/../tbsexport/car.war /home/$U/Desktop/`
cd /home/$U/Desktop/
`rm -rf car`
mkdir car
cd car
echo "extract tar file"
jar xf ../car.war
echo "rename file"
cd ..
#mv car/ car/
echo "move war in tomcat"
mv car/ $TOMCAT_DIRECTORY_PATH/webapps/
echo "replace email properties file in tomcat"
cp $BACKUP_DIRECTORY_PATH/$NOW/car/WEB-INF/classes/emailProperties.properties $TOMCAT_DIRECTORY_PATH/webapps/car/WEB-INF/classes
if test $? -eq 0 ; then
echo "email properties copy successfully";
else
echo "copy in email properties";
exit 1;
fi
echo "replace SMSMessageSendResource properties file in tomcat"
cp -rv $BACKUP_DIRECTORY_PATH/$NOW/car/WEB-INF/classes/SMSMessageSendResource.properties $TOMCAT_DIRECTORY_PATH/webapps/car/WEB-INF/classes
if test $FLAG -eq 0 ; then
echo "replace applicationContext properties file in tomcat"
cp -rv $BACKUP_DIRECTORY_PATH/$NOW/car/WEB-INF/classes/applicationContext.xml $TOMCAT_DIRECTORY_PATH/webapps/car/WEB-INF/classes
else
sudo python applicationContextChange.py $TOMCAT_DIRECTORY_PATH/webapps/car/WEB-INF/classes #provide custom ip default localhost
sudo mv output.xml $TOMCAT_DIRECTORY_PATH/webapps/car/WEB-INF/classes/applicationContext.xml
fi
echo "replace scriptsconfig properties file in tomcat"
cp -rv $BACKUP_DIRECTORY_PATH/$NOW/car/WEB-INF/classes/scriptsconfig.properties $TOMCAT_DIRECTORY_PATH/webapps/car/WEB-INF/classes
echo "replace lib in tomcat"
sudo rm -rf $TOMCAT_DIRECTORY_PATH/webapps/car/WEB-INF/lib/
cp -rv $BACKUP_DIRECTORY_PATH/$NOW/car/WEB-INF/lib/ $TOMCAT_DIRECTORY_PATH/webapps/car/WEB-INF/
if test $? -eq 0 ; then
echo "move lib successfully";
else
echo "error in move"
fi
rm -rf /home/$U/Desktop/car.war
chmod -R 777 $TOMCAT_DIRECTORY_PATH/webapps/car/WEB-INF/
echo "sucessfully create war file."
#starting the tomcat
echo "starting the tomcat"
cd $TOMCAT_DIRECTORY_PATH/bin/
sh catalina.sh jpda start
if test $? -eq 0 ; then
echo "Started the tomcat";
else
echo "Alert!! tomcat was NOT Started";
exit 1
fi