Subversion Repositories SmartDukaan

Rev

Rev 22427 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 22427 Rev 35873
Line 1... Line 1...
1
#!/bin/bash
1
#!/bin/bash
2
 
2
 
3
# Deploy the war
3
# ===== CONFIG =====
-
 
4
PROJECT_DIR="/root/code/trunk"
-
 
5
BUILD_WAR="$PROJECT_DIR/profitmandi-web/build/libs/profitmandi-web-0.0.1-SNAPSHOT.war"
-
 
6
TOMCAT_DIR="/opt/tomcat"
-
 
7
WEBAPPS_DIR="$TOMCAT_DIR/webapps"
-
 
8
BACKUP_DIR="$TOMCAT_DIR/backup"
4
 
9
 
5
#sh $TOMCAT_HOME/bin/shutdown.sh
10
echo "Starting Deployment..."
6
 
11
 
7
pkill -9 -f tomcat
12
# Move to project directory
-
 
13
set -e
8
echo "deleting old profitmandi-fofo.war profitmandi-fofo directory";
14
cd $PROJECT_DIR/profitmandi-dao || exit
9
echo "deleting old profitmandi-admin.war profitmandi-admin directory";
-
 
10
echo "deleting old profitmandi-web.war profitmandi-web directory";
15
echo "🔄 Updating dao for staging from SVN..."
-
 
16
svn up
11
 
17
 
12
`rm -rf $TOMCAT_HOME/webapps/profitmandi-fofo*`;
18
cd $PROJECT_DIR/profitmandi-common || exit
13
if [ $? -ef 0 ]; then
-
 
14
	echo "profitmandi-fofo.war and profitmandi-fofo directroy has been removed successfully.";
19
echo "🔄 Updating common for staging from SVN..."
15
else
20
svn up
-
 
21
 
-
 
22
cd $PROJECT_DIR/profitmandi-web || exit
16
	echo "profitmandi-fofo.war and profitmandi-fofo directroy deletion failed.";
23
echo "🔄 Updating web for staging from SVN..."
17
fi 
24
svn up
18
 
25
 
19
`rm -rf $TOMCAT_HOME/webapps/profitmandi-admin*`;
26
echo "🔨 Building project..."
-
 
27
gradle build -x test
-
 
28
 
20
if [ $? -ef 0 ]; then
29
if [ ! -f "$BUILD_WAR" ]; then
21
        echo "profitmandi-admin.war and profitmandi-admin directroy has been removed successfully.";
30
  echo "Build failed! WAR file not found."
22
else
31
  exit 1
23
        echo "profitmandi-admin.war and profitmandi-admin directroy deletion failed.";
-
 
24
fi
32
fi
25
 
33
 
26
`rm -rf $TOMCAT_HOME/webapps/profitmandi-web*`;
-
 
27
if [ $? -eq 0 ]; then
-
 
28
	echo "profitmandi-web.war and profitmandi-web directory has been removed successfully.";
-
 
29
	echo "profitmandi-web.war is deploying... to tomcat container";
-
 
30
	cp target/profitmandi-web-0.0.1-SNAPSHOT.war $TOMCAT_HOME/webapps/profitmandi-web.war
-
 
31
	if [ $? -eq 0 ]; then
-
 
32
		echo "profitmandi-fofo.war has been deployed successfully.";
-
 
33
		echo "freshing the catalina.out file";
34
echo "Stopping Tomcat..."
34
		>$TOMCAT_HOME/logs/catalina.out;
35
$TOMCAT_DIR/bin/shutdown.sh
35
		if [ $? -eq 0 ]; then
36
sleep 5
36
			echo "catalina.out has been refreshed.";
-
 
37
		fi
37
 
38
		echo "tomcat container is being starting...";
38
echo "Creating backup..."
39
		sh $TOMCAT_HOME/bin/startup.sh
-
 
40
		if [ $? -eq 0 ]; then
39
mkdir -p $BACKUP_DIR
41
			echo "tomcat container has been started successfully.";
-
 
42
			echo "opening application logs";
-
 
43
			#tail -f /home/ashikali/apache-tomcat-8.0.43/logs/catalina.out
-
 
44
			tail -f $TOMCAT_HOME/logs/catalina.out
-
 
45
		else
-
 
46
			echo "tomcat container is failed to start";
-
 
47
		fi
-
 
48
	else 
-
 
49
		echo "profitmandi-web.war deployment failed.";
40
if [ -f "$WEBAPPS_DIR/profitmandi-web.war" ]; then
50
	fi
-
 
51
else 
-
 
52
	echo "profitmandi-web.war or profitmandi-fofo directory deletion failed.";
41
  cp $WEBAPPS_DIR/profitmandi-web.war $BACKUP_DIR/profitmandi-web_$(date +%Y%m%d%H%M%S).war
53
fi
42
fi
-
 
43
 
-
 
44
echo "Removing old deployment..."
-
 
45
rm -rf $WEBAPPS_DIR/profitmandi-web
-
 
46
rm -f $WEBAPPS_DIR/profitmandi-web.war
-
 
47
 
-
 
48
echo "Copying new WAR..."
-
 
49
cp $BUILD_WAR $WEBAPPS_DIR/profitmandi-web.war
-
 
50
 
-
 
51
echo "Starting Tomcat..."
-
 
52
$TOMCAT_DIR/bin/startup.sh
-
 
53
 
-
 
54
echo "Deployment Completed Successfully!"
54
55