-
Notifications
You must be signed in to change notification settings - Fork 1
/
tomcatctl.sh
executable file
·112 lines (97 loc) · 1.88 KB
/
tomcatctl.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
#!/bin/sh
#
# tomcatctl Script for control tomcat.
#
# chkconfig: 345 99 99
# description: tomcatctl is a script for control tomcat.
# Change this to tomcat user
OPERATOR=dev
# Change this to real tomcat dir
TOMCATS=( /opt/tomcat/tomcat-foo /opt/tomcat/tomcat-bar )
#TM_REGEX=""
#for TM in ${TOMCATS[@]}
#do
# TM_REGEX="$TM_REGEX$TM\|"
#done
#if [ $TM_REGEX != "" ] ; then
#TM_REGEX=""
#fi
# Shell return value
RETVAL=0
start()
{
for TM in ${TOMCATS[@]}
do
su - $OPERATOR -c "cd $TM; rm -rf work/*; bin/startup.sh"
echo "$TM startup."
done
if [ "$TOMCATS" = "" ] ; then
echo "There is no tomcat configed."
else
echo "All tomcats startup."
fi
}
stop()
{
PIDS=( `jps -l |grep catalina |awk '{print $1}'` )
for PID in ${PIDS[@]}
do
echo "Shutdown tomcat[$PID]..."
kill $PID
done
if [ "$PIDS" = "" ] ; then
echo "There is no tomcat running."
else
echo "Waiting for tomcats shutdown..."
sleep 5
fi
PIDS=( `jps -l |grep catalina |awk '{print $1}'` )
if [ "$PIDS" = "" ] ; then
echo "All tomcats shutdown normally."
else
for PID in ${PIDS[@]}
do
echo "kill -9 tomcat[$PID]..."
kill -9 $PID
done
echo "All tomcats is killed."
fi
}
restart()
{
stop
start
}
status()
{
jps -ml |grep catalina
}
help()
{
echo "Usage: $0 [OPTION]"
echo ""
echo " start start tomcat"
echo " stop stop tomcat"
echo " restart restart tomcat"
echo " status show started tomcat pid"
echo " help display this help and exit"
echo ""
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
status)
status
;;
*)
help
RETVAL=1
esac
exit $RETVAL