shell指令碼原始碼安裝tomcat
#!/bin/bash
##tomcat install
##2018.11.23
##tomcat版本8.5.35,jdk-8u191-linux-x64.tar
PWD=/usr/local/src
DIR=/usr/local
IP=$(ip a |grep "scope global" |awk '{print $2}'|awk -F '/' '{print $1}')
yum -y install lrzsz wget unzip vim lsof
echo "------------------------------安裝JDK--------------------------"
if [ -f $PWD/jdk-8u191-linux-x64.tar.gz ];then
cd $PWD
if [ -d $PWD/jdk1.8.0_191 ];then
echo "檢測到JDK1.8.0_191,刪除重新解壓"
rm -rf $PWD/jdk1.8.0_191
tar xf $PWD/jdk-8u191-linux-x64.tar.gz -C $PWD
else
echo "未檢測到JDK1.8.0_191,開始解壓..."
tar xf $PWD/jdk-8u191-linux-x64.tar.gz -C $PWD
fi
else
echo "未檢測到jdk-8u191-linux-x64.tar.gz ,開始下載https://download.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/jdk-8u191-linux-x64.tar.gz?AuthParam=1542943486_ea7b795db30eb5d75941d7efd70be380"
wget '
fi
rpm -qa |grep java
cd $PWD && mv $PWD/jdk1.8.0_191/ $DIR/java
java -version
if [ $? -ne 0 ];then
echo "增加java環境變數"
echo "export JAVA_HOME=$DIR/java">>/etc/profile
echo "export PATH=$PATH:/$DIR/java/bin">>/etc/profile
source /etc/profile
else
echo "java變數已設定"
fi
echo "檢視JDK版本資訊"
java -version
echo "-------------------------------安裝tomcat---------------------"
if [ -f $PWD/apache-tomcat-8.5.35.tar.gz ];then
cd $PWD
if [ -d $PWD/apache-tomcat-8.5.35 ];then
echo "檢測到apache-tomcat-8.5.35,刪除重新解壓... "
rm -rf $PWD/apache-tomcat-8.5.35
tar zxvf $PWD/apache-tomcat-8.5.35.tar.gz -C $PWD
else
echo "未檢測到apache-tomcat-8.5.35目錄,開始解壓..."
tar zxvf $PWD/apache-tomcat-8.5.35.tar.gz -C $PWD
fi
else
echo "未檢測到apache-tomcat-8.5.35.tar.gz軟體包,開始下載http://124.205.69.163/files/5015000007330888/mirror.bit.edu.cn/apache/tomcat/tomcat-8/v8.5.35/bin/apache-tomcat-8.5.35.tar.gz"
cd $PWD
wget '
fi
if [ -d $DIR/tomcat ];then
echo "檢測到tomcat目錄,刪除複製"
rm -rf $DIR/tomcat
mv $PWD/apache-tomcat-8.5.35 $DIR/tomcat
else
echo "未檢測到tomcat目錄,開始複製..."
mv $PWD/apache-tomcat-8.5.35 $DIR/tomcat
fi
echo "--------------------匯入tomcat的配置檔案-----------------"
cat $DIR/src/server.xml>$DIR/tomcat/conf/server.xml
cat $DIR/src/catalina.sh>$DIR/tomcat/bin/catalina.sh
echo "---------------------啟動tomcat---------------------"
/usr/local/tomcat/bin/startup.sh
echo "檢視啟動情況"
lsof -i:8080
netstat -utpln |grep 80