#! /bin/bash
#环境:jdk-8u201-linux-x64,tomcat
cd /opt
yum install -y wget
#下载jdk和tomcat安装包
wget http://192.168.3.200/package/gz/jdk-8u201-linux-x64.tar.gz
wget http://192.168.3.200/package/gz/apache-tomcat-8.5.59.tar.gz
gunzip jdk-8u201-linux-x64.tar.gz
tar -xvf jdk-8u201-linux-x64.tar
#设置jdk环境变量
echo 'export JAVA_HOME=/opt/jdk1.8.0_201' >> /etc/profile
echo 'export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar' >> /etc/profile
echo 'export PATH=$JAVA_HOME/bin:$PATH' >> /etc/profile
/opt/jdk1.8.0_201/bin/jps
if [ $? -eq 0 ]
then
gunzip apache-tomcat-8.5.59.tar.gz
tar -xvf apache-tomcat-8.5.59.tar
mv apache-tomcat-8.5.59 /usr/local/tomcat
else
echo "jdk安装有问题,请修改脚本,否则没有办法再进行下去"
fi
source /etc/profile
/usr/local/tomcat/bin/catalina.sh start
if [ $? -eq 0 ]
then
echo "tomcat已经启动,可通过ps -ef | grep tomcat查看进程"
else
echo "尝试手动执行一遍 source /etc/profile 命令"
fi
02-18