tomcatctl.sh
1.29 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
#!/bin/bash
################################################################
#@Authro Lijian
#@Date 2015-10-22
################################################################
BASE_BIN_DIR=`dirname $0`
. $BASE_BIN_DIR/env.sh
export CATALINA_HOME=$SERVER_HOME
export CATALINA_BASE=$WEB_APP_HOME/.tomcat
CATALINA_BASE=$WEB_APP_HOME/.tomcat
################################################################
##check if started before
check_server(){
java_pid=`ps --no-heading -C java -f --width 1000 | grep "$$CATALINA_BASE" |awk '{print $2}'`
if [ ! -z "$java_pid" ]; then
echo "Tomcat server already started: pid=$java_pid"
exit;
fi
}
copy_server_home(){
if [ -d "$CATALINA_BASE" ]; then
rm -rf $CATALINA_BASE
fi
mkdir -p $CATALINA_BASE/conf
mkdir -p $CATALINA_BASE/webapps
mkdir -p $CATALINA_BASE/logs
touch $CATALINA_BASE/logs/catalina.out
}
copy_tomcat_conf(){
cp -rf $SERVER_HOME/conf/. $CATALINA_BASE/conf/.
cp -rf $WEB_APP_HOME/conf/tomcat/server.xml $CATALINA_BASE/conf/server.xml
}
copy_war(){
cp -rf $WEB_APP_HOME/*.war $CATALINA_BASE/webapps/
}
deploy(){
check_server
copy_server_home
copy_tomcat_conf
copy_war
}
###############################################################
deploy
$SERVER_HOME/bin/catalina.sh start