Linux环境编写脚本安装配置JDK,Tomcat,含Tomcat自启动
Posted 星朝
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux环境编写脚本安装配置JDK,Tomcat,含Tomcat自启动相关的知识,希望对你有一定的参考价值。
- mkdir /usr/java
- mkdir /znywImage
-
- cp -f /usr/jdk-7u79-linux-x64.tar.gz /usr/java
-
- tomcatPath=/usr/apache-tomcat-8.5.20
- if [ -d "$tomcatPath" ]; then
- echo "删除$tomcatPath目录"
- sudo rm -rf $tomcatPath
- echo "目录$tomcatPath删除成功"
- fi
-
- jdkPath=/usr/java/jdk1.7.0_79
- if [ -d "$jdkPath" ]; then
- echo "删除$jdkPath目录"
- sudo rm -rf $jdkPath
- echo "目录$jdkPath删除成功"
- fi
-
- tar -xzvf /usr/apache-tomcat-8.5.20.tar.gz -C /usr
- tar -xzvf /usr/java/jdk-7u79-linux-x64.tar.gz -C /usr/java
-
-
-
-
- myfile=/usr/etc/profile
- echo "原来文件的总行数"
- awk ‘END{print NR}‘ $myfile
-
- echo "jdk开始的行数"
- grep -an "export JAVA_HOME=/usr/java/" $myfile |cut -d: -f1
-
- echo "jdk结束的行数"
- grep -an "export PATH=" $myfile |cut -d: -f1
-
- echo "开始准备删除文件中的重复数据"
- startLine=$(grep -an "export JAVA_HOME=/usr/java/" $myfile |cut -d: -f1)
- endLine=$(grep -an "export PATH=" $myfile |cut -d: -f1)
- sed -i $startLine‘,‘$endLine‘d‘ $myfile
- echo "删除完毕!!!!"
-
- echo "文件剩余行数"
- awk ‘END{print NR}‘ $myfile
-
- echo "测试结束!!"
-
-
-
-
-
- echo "export JAVA_HOME=/usr/java/jdk1.7.0_79" >> /etc/profile
- echo "export JRE_HOME=/usr/java/jdk1.7.0_79/jre" >> /etc/profile
- echo "export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib" >> /etc/profile
- echo "export PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin" >> /etc/profile
-
-
-
-
-
- cp -f /usr/server.xml /usr/apache-tomcat-8.5.20/conf
- echo "server.xml移动成功"
-
- `source /etc/profile`
- source /etc/profile
- javac
- echo "配置环境成功"
- echo "测试是否安装成功"
以上是关于Linux环境编写脚本安装配置JDK,Tomcat,含Tomcat自启动的主要内容,如果未能解决你的问题,请参考以下文章
linux自动部署--sh脚本安装jdk,tomcat,mysqlclient