标签:jdk The 编写 file 安装 测试 gre lang 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自启动
标签:jdk The 编写 file 安装 测试 gre lang tomcat
原文地址:https://www.cnblogs.com/jpfss/p/9713738.html