shell脚本简单搭建测试环境
本地环境,未加过多复杂判断条件
#!/bin/bash #配置JDK decomp_jdk(){ tar -xzvf /opt/jdk-8u131-linux-i586.tar.gz tar -xzvf /opt/apache-tomcat-8.5.39.tar.gz #环境变量 chmod u+x,g+wx ~/.bashrc cd ~ sed -i '$aJAVA_HOME=/opt/jdk1.8.0_131' .bashrc sed -i '$aPATH=$PATH:$JAVA_HOME/bin' .bashrc sed -i '$aCLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JRE_HOME/lib/tools.jar' .bashrc source ~/.bashrc echo "successful" } decomp_jdk
#配置mysql decomp_mysql(){ echo y|yum install mysql-server service mysqld start echo "successful" mysqladmin -uroot password 123456 mysql -uroot -p123456 <<EOF create database db_shopping; use db_shopping; source /opt/db_shopping.sql; GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION; FLUSH PRIVILEGES; commit; exit; EOF } decomp_mysql #tomcat启动,war包部署 decomp_tom(){ echo y|cp /opt/Shopping.war /opt/apache-tomcat-8.5.39/webapps cd /opt/apache-tomcat-8.5.39/bin ./startup.sh iptables -F } decomp_tom