-
Notifications
You must be signed in to change notification settings - Fork 0
/
jdk-tomcat_deploy.sh
72 lines (69 loc) · 2.1 KB
/
jdk-tomcat_deploy.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
#!/bin/bash
#
#
#
SRC=/usr/local/src
LOCATE=/usr/local
JDK="jdk-8u91-linux-x64.gz"
JDK18="jdk1.8.0_91"
TOMCAT="apache-tomcat-7.0.67.tar.gz"
TOMCAT7="apache-tomcat-7.0.67"
jdk_deploy(){
tar xf $SRC/$JDK
mv $SRC/$JDK18 $LOCATE/jdk1.8
cat > /etc/profile.d/jdk1.8.sh << "EOF"
JAVA_HOME=/usr/local/jdk1.8
JRE_HOME=$JAVA_HOME/jre
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
CLASSPATH=:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
export JAVA_HOME JRE_HOME PATH CLASSPATH
EOF
chmod +x /etc/profile.d/jdk1.8.sh
source /etc/profile.d/jdk1.8.sh
}
tomcat_deploy(){
tar xf $SRC/$TOMCAT
mv $SRC/$TOMCAT7 $LOCATE
cd $LOCATE
ln -s $TOMCAT7 tomcat
#为tomcat设置UTF-8编码
sed -i -e '/connectionTimeout="20000"/a\URIEncoding="UTF-8"' $LOCATE/tomcat/conf/server.xml
#为tomcat设置单独的环境变量路径,防止主机存在2个以上tomcat时启动出现冲突
sed -i -e '/\#\!\/bin\/sh/a\export TOMCAT_HOME=/usr/local/tomcat\nexport CATALINA_HOME=/usr/local/tomcat\nexport JRE_HOME=/usr/local/jdk1.8/jre\nexport JAVA_HOME=/usr/local/jdk1.8
JAVA_OPTS="-Dfile.encoding=utf-8 -Duser.timezone=Asia/Shanghai"
export CATALINA_OPTS="$CATALINA_OPTS
-Dcom.sun.management.jmxremote=true
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.port=8090
-Dcom.sun.management.jmxremote.authenticate=false
-Djava.rmi.server.hostname=10.80.227.108" ' $LOCATE/tomcat/bin/catalina.sh
}
deploy(){
clear
echo "################众信普惠jdk与tomcat自动安装工具############"
echo "# #"
echo "# 0.自动安装jdk与tomcat #"
echo "# 1.安装jdk #"
echo "# 2.安装tomcat #"
echo "# 3.退出 #"
echo "###########################################################"
read -p "请输入选项:" ID
case $ID in
0)
jdk_deploy&&tomcat_deploy
;;
1)
jdk_deploy
;;
2)
tomcat_deploy
;;
3)
exit 0
;;
*)
echo "输入不合法,请重新输入检测输入信息" && deploy
;;
esac
}
deploy