tomcat发布脚本

tomcat发布脚本

十月 22, 2018

tomcat发布脚本

##tomcat环境发布web脚本

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
#!/bin/sh

a=''
# check arguments
if [ x$1 != x ]
then
a=$1
else
echo 'warn....请选择您要部署的项目'
exit 0
fi

rm -rf ./$a
echo '-----------------:'$a
mkdir $a
cp $a.war ./$a

cd $a
jar xvf *.war
rm -rf *.war
rm -rf ./WEB-INF/lib/zft*.jar
rm -rf ./WEB-INF/classes/platform.properties


cp /home/chengdu/initWar/files/*.jar ./WEB-INF/lib/
cp /home/chengdu/initWar/files/platform.properties ./WEB-INF/classes/

jar cvf $a.war ./*

###############
ps -ef | grep tomcat | grep $a | awk '{print $2}' | sed -e "s/^/kill -9 /g" | sh -


rm -rf /home/chengdu/webapps/xxx/$a
rm -rf /home/chengdu/webapps/xxx/$a.war
rm -rf /home/chengdu/tomcat/xxx/work/Catalina/localhost/$a
cp $a.war /home/chengdu/webapps/$a
/home/chengdu/tomcat/xxxx/bin/startup.sh

echo -e '\n\n'
b=`ps -ef | grep tomcat | grep $a`


echo -e '\n\n'
echo $b

echo -e '\n\n'
#### str is empty
if [ "$b"x != ""x ]
then
echo 'startup success........'
else
echo 'start failed..........请手动操作'
exit 0
fi


echo -e '\n\n'
### see log

read -p "please input (y or n) 查看日志(y)..." -t 15 char
# str eq
if [ "$char"x = "y"x ]
then
tail -f /home/chengdu/tomcat/xxx/logs/catalina.out
else
exit 0
fi