Shell tomcat多实例部署
[root@localhost ~]# cat auto_install_tomcat.sh
#!/bin/bash
#install java jdk
jdk_ver="1.8.0_131"
jdk_soft="jdk${jdk_ver}.tar.gz"
jdk_dir="/usr/java"
jdk_src=$(echo $jdk_soft | sed 's/.tar.gz//g')
if [ -d $jdk_dir ];then
echo -e "\033[32mStart config java jdk,please wait............\033[0m"
cd /usr/src
mkdir -p $jdk_dir
tar xf $jdk_soft -C $jdk_dir
ls -l $jdk_dir/$jdk_src
cat >>/etc/profile<<EOF
export JAVA_HOME=$jdk_dir/$jdk_src
export CLASSPATH=\$CLASSPATH:\$JAVA_HOME/lib:\$JAVA_HOME/jre/lib
EOF
source /etc/profile
fi
#config tomcat web service
echo -e "\033[32mStart config tomcat,please wait............\033[0m"
tomcat_ver="8.0.39"
tomcat_soft=" apache-tomcat-${tomcat_ver}.tar.gz"
tomcat_dir='/usr/local'
tomcat_src=$(echo $tomcat_soft | sed 's/.tar.*//g')
tomcat_vhost="$1"
tomcat_max_port=$(for i in `find /usr/local/ -name server.xml`;do grep "port=" $i;done|sed 's/ /\n/g'|grep "port="|grep -vE "8080|8443" | awk -F '"' '{print $2}' |sort -n | tail -1)
if [ -z $tomcat_max_port ];then
tar xf $tomcat_soft -C $tomcat_dir
mv $tomcat_dir/$tomcat_src $tomcat_dir/$tomcat_vhost
ls -l $tomcat_dir/$tomcat_vhost
$tomcat_dir/$tomcat_vhost/bin/startup.sh
sleep 3s
netstat -tpln | grep -wE "8005|8080|8009"
exit 0
else
tar xf $tomcat_soft -C $tomcat_dir
mv $tomcat_dir/$tomcat_src $tomcat_dir/$tomcat_vhost
port1=$((tomcat_max_port+100))
port2=$((tomcat_max_port+101))
port3=$((tomcat_max_port+102))
sed -n 's/<Server port=.*/<Server port='"$port1"' shutdown="SHUTDOWN">/p' $tomcat_dir/$tomcat_vhost/conf/server.xml
fi
[root@localhost ~]# jdk_src=$(echo jdk1.8.0_131.tar.gz | sed 's/.tar.//g')
[root@localhost ~]# echo $jdk_src
jdk1.8.0_131gz
[root@localhost ~]# jdk_src=$(echo jdk1.8.0_131.tar.gz | sed 's/.tar*//g')
[root@localhost ~]# echo $jdk_src
jdk1.8.0_131.gz
[root@localhost ~]# jdk_src=$(echo jdk1.8.0_131.tar.gz | sed 's/.tar.*//g')
[root@localhost ~]# echo $jdk_src
jdk1.8.0_131
目录 返回
首页