-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.sh
More file actions
87 lines (68 loc) · 2.03 KB
/
Copy pathmain.sh
File metadata and controls
87 lines (68 loc) · 2.03 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
#! /bin/bash
typeset flag=0
# get the environment varaibles from the config file
. config/webtop_deploy_config
# check if the webtop app name is exist or not
if [[ $# != 1 ]] ; then
echo 'Please input the webtop app name'
exit
fi
user=$(whoami)
if [[ $user == "root" ]]; then
echo "Please DO NOT run this tool as ROOT"
exit 1
fi
# check if the log dir exists or not
if [[ ! -d log ]] ; then
mkdir log
fi
# check if the build dir exists or not
if [[ ! -d $buildDir ]]; then
mkdir -p $buildDir
fi
# define the web app url and app directory
appURL=$webtopHost$1
appDir=${tomcatDir}webapps/$1
# get war from remote server
if [[ $1 == http* ]] ; then
echo 'Get the war package from build server ' $1
flag=1
wget -P $buildDir $1 > log/download.log 2>&1
war=$(cat log/download.log | grep saved | awk -F \' '{print $2}' | awk -F \' '{print $1}' | awk -F / '{print $NF}')
# get war from local
elif [[ $1 == *war ]] ; then
flag=2
echo 'Get war from local'
war=$(ls -ltr $buildDir*.war | awk -F '/' {'print $NF'} | tail -1 )
version=$(echo ${new_war%.*} | awk -F 'se-' {'print $NF'})
#war=${new_war}_${version}
fi
# unzip war if needed
if [[ flag -ne 0 ]] ; then
version=$(echo ${war%.*} | awk -F 'se-' '{print $NF}')
appDir=${tomcatDir}webapps/ux2.2_$version
rm -rf ${tomcatDir}webapps/ux2.2_$version
unzip $buildDir$war -d $appDir > log/unzip.log 2>&1
fi
sudo chmod 755 $appDir
sudo chown -R imail1:imail $appDir
# stop tomcat if deploy a new war
if [[ flag -ne 0 ]]; then
./lib/restart_tomcat_or_webapp.sh $1 'stop'
fi
# back up for webtop config
echo 'back up for webtop config'
cp $appDir/WEB-INF/classes/config/webtop-config.xml $appDir/WEB-INF/classes/config/webtop-config_backup.xml
# update webtop config
if [[ flag -eq 0 ]]; then
./lib/update_webtop_config_cpms.sh $1
else
./lib/update_webtop_config_cpms.sh ux2.2_$version
fi
# restart webapps or start tomcat
if [[ flag -eq 0 ]] ; then
./lib/restart_tomcat_or_webapp.sh $1 'restart'
else
./lib/restart_tomcat_or_webapp.sh $1 'start'
fi
echo 'the url is :' ${appURL}