-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMtomcat
More file actions
69 lines (59 loc) · 1.4 KB
/
Mtomcat
File metadata and controls
69 lines (59 loc) · 1.4 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
#!/bin/sh
#
#description:
#Mtomcat This is the script to restart tomcat in rotation
#
#### BEGIN INFO
# Provides: maycap
# Required-Start: null
# Should-Start: null
# version:1.0
# date:2015-6-19
### END INFO
list=$1
host=$2
#check parameters number
if [ $# -ne 2 ];then
echo -e "\e[1;32m`basename $0` need two parameters"
echo -e "Usage: `basename $0` list host \e[0m"
exit 1
fi
#check list is exist
if [ -f $list ];then
:
else
echo -e "\e[1;31mNot found list $list!\e[0m"
exit 2
fi
#check host is connect
ssh $host hostname 2>/dev/null 1>/dev/null
if [ $? -ne 0 ];then
echo -e "\e[1;31mNot connect host $host!\e[0m"
exit 3
fi
SERVICEPATH='/web/service'
TMPFILE=/tmp/$$
touch $TMPFILE
#Search the tomcat for compliance and write result lists to TMPFILE
for i in `cat $list`
do
result=`ssh $host find $SERVICEPATH -maxdepth 5 -name $i.xml`
if [ ${#result} -gt 2 ];then
path=`echo $result | awk -F '/conf' '{print $1}'`
echo $path >> $TMPFILE
fi
done
#restart tomcat list in rotation
#ssh not load the host environment variable,so you should load something(/etc/profile) by hand.
for j in `cat $TMPFILE | sort | uniq`
do
echo -e "\e[1;32mNow restart $host $j...\e[0m"
ssh $host "source /etc/profile;$j/bin/shutdown.sh"
ssh $host "rm -fr $j/logs/*"
ssh $host "rm -fr $j/log/*"
ssh $host "rm -fr $j/work/*"
sleep 3
ssh $host "source /etc/profile;$j/bin/startup.sh"
done
#rm the temp file
rm -fr $TMPFILE