Linux安裝JDK&Tomcat(shell指令碼)&軟體安裝之JDK&T
阿新 • • 發佈:2018-12-21
1.編寫installJdkTomcat.sh指令碼
#!/bin/bash myDir=`pwd` rpm -qa | grep jdk > jdk.txt grep "jdk" $myDir/jdk.txt > /dev/null if [ $? -eq 0 ]; then echo "Install JDK" else rpm -ivh jdk-7u21-linux-x64.rpm rpm -qa | grep jdk > jdk.txt fi rpm -ql `cat jdk.txt | awk '{print $1}'` | grep /release > jdk2.txt myJdk=`cat jdk2.txt` javaHome=${myJdk//release/""} echo ${javaHome} grep "JAVA_HOME" /etc/profile > /dev/null if [ $? -eq 0 ]; then echo "Has JAVA HOME" else echo "export JAVA_HOME=$javaHome" >> /etc/profile echo "export PATH=\$PATH:$javaHome/bin" >> /etc/profile source /etc/profile fi if [ ! -d "$myDir/apache-tomcat-7.0.33" ];then unzip -x apache-tomcat-7.0.33.zip fi
2.修改installJdkTomcat.sh的執行屬性
chmod +x installJdk.sh
3.執行installJdk.sh將安裝Jdk&Tomcat,並配置JDK環境變數,解壓Tomcat