✨ 添加环境部署脚本
parent
595ce49294
commit
03fa4d3542
|
@ -0,0 +1,85 @@
|
|||
#!/bin/bash
|
||||
###################################################################################
|
||||
# 环境部署脚本
|
||||
###################################################################################
|
||||
|
||||
function printBeginning() {
|
||||
cat << EOF
|
||||
***********************************************************************************
|
||||
* Welcome to using the deployment script for linux.
|
||||
* Author: Zhang Peng
|
||||
***********************************************************************************
|
||||
EOF
|
||||
}
|
||||
|
||||
function printEnding() {
|
||||
cat << EOF
|
||||
***********************************************************************************
|
||||
* Deployment is over.
|
||||
* Thank you for using!
|
||||
***********************************************************************************
|
||||
EOF
|
||||
}
|
||||
|
||||
function checkOsVersion(){
|
||||
if(($1 == 1))
|
||||
then
|
||||
platform=`uname -i`
|
||||
if [ $platform != "x86_64" ];then
|
||||
echo "this script is only for 64bit Operating System !"
|
||||
exit 1
|
||||
fi
|
||||
echo "the platform is ok"
|
||||
version=`lsb_release -r |awk '{print substr($2,1,1)}'`
|
||||
if [ $version != 6 ];then
|
||||
echo "this script is only for CentOS 6 !"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
function showMenu() {
|
||||
cat << EOF
|
||||
|
||||
====================================== Deploy Menu ======================================
|
||||
【1 - System Environment】
|
||||
【2 - Common Tools】
|
||||
[2 | tools] install all tools.
|
||||
[2-1 | git] install git. [2-2 | jdk8] install jdk8.
|
||||
[2-3 | maven] install maven. [2-4 | nginx] install nginx.
|
||||
[2-5 | nodejs] install node.js. [2-6 | tomcat] install tomcat8.
|
||||
|
||||
按下 <CTRL-D> 退出。
|
||||
请输入 key:
|
||||
EOF
|
||||
}
|
||||
|
||||
key=""
|
||||
filepath=$(cd "$(dirname "$0")"; pwd)
|
||||
function chooseOper() {
|
||||
while read key
|
||||
do
|
||||
case ${key} in
|
||||
2 | tools) ${filepath}/tool/install-all.sh;;
|
||||
2-1 | git) ${filepath}/tool/git/install-git.sh;;
|
||||
2-2 | jdk8) ${filepath}/tool/jdk/install-jdk8.sh;;
|
||||
2-3 | maven) ${filepath}/tool/maven/install-maven.sh;;
|
||||
2-4 | nginx) ${filepath}/tool/nginx/install-nginx.sh;;
|
||||
2-5 | nodejs) ${filepath}/tool/nodejs/install-nodejs.sh;;
|
||||
2-6 | tomcat) ${filepath}/tool/tomcat/install-tomcat8.sh;;
|
||||
* ) echo "invalid key";;
|
||||
esac
|
||||
|
||||
showMenu
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
|
||||
######################################## MAIN ########################################
|
||||
printBeginning
|
||||
checkOsVersion 0
|
||||
showMenu
|
||||
chooseOper
|
||||
printEnding
|
|
@ -0,0 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
echo -e "\n>>>>>>>>> install git"
|
||||
|
||||
yum -y install git
|
|
@ -0,0 +1,10 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
echo -e "\n>>>>>>>>> install all tools"
|
||||
|
||||
./git/install-git.sh
|
||||
./jdk/install-jdk8.sh
|
||||
./maven/install-maven3.sh
|
||||
./nginx/install-nginx.sh
|
||||
./nodejs/install-nodejs.sh
|
||||
./tomcat/install-tomcat8.sh
|
|
@ -0,0 +1,25 @@
|
|||
#!/bin/bash
|
||||
|
||||
echo -e "\n>>>>>>>>> install jdk8"
|
||||
|
||||
wget http://download.oracle.com/otn-pub/java/jdk/7u79-b15/jdk-7u79-linux-x64.rpm?AuthParam=1471671456_14c9442ffc64438c1b8fc83587ecdf47
|
||||
path = './jdk-7u79-linux-x64.rpm'
|
||||
|
||||
echo '正在安装JDK...'
|
||||
#update java
|
||||
for installedJava in $(rpm -qa |grep java);do
|
||||
rpm -e --nodeps $installedJava
|
||||
done
|
||||
rpm -ivh $path
|
||||
sunJava=$(ls /usr/java |grep jdk)
|
||||
if [ "$sunJava" != "" ];then
|
||||
cat >/etc/profile.d/java.sh<<EOF
|
||||
JAVA_HOME=/usr/java/$sunJava
|
||||
PATH=$JAVA_HOME/bin:\$PATH
|
||||
CLASSPATH=.:\$JAVA_HOME/lib/dt.jar:\$JAVA_HOME/lib/tools.jar
|
||||
export JAVA_HOME
|
||||
export PATH
|
||||
export CLASSPATH
|
||||
EOF
|
||||
chown root.root /etc/profile.d/java.sh
|
||||
fi
|
|
@ -0,0 +1,10 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
echo -e "\n>>>>>>>>> install maven"
|
||||
|
||||
mkdir -p /opt/software/maven
|
||||
cd /opt/software/maven
|
||||
|
||||
version=3.5.2
|
||||
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://mirrors.shuosc.org/apache/maven/maven-3/${version}/binaries/apache-maven-${version}-bin.tar.gz
|
||||
tar -zxvf apache-maven-${version}-bin.tar.gz
|
|
@ -0,0 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
echo -e "\n>>>>>>>>> install nginx"
|
||||
|
||||
yum -y install make nginx.x86_64
|
|
@ -0,0 +1,11 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
echo -e "\n>>>>>>>>> install Node.js"
|
||||
|
||||
# 安装 nvm
|
||||
rm -rf /home/admin/.nvm
|
||||
git clone https://github.com/creationix/nvm.git ~/.nvm && cd ~/.nvm
|
||||
source ~/.nvm/nvm.sh
|
||||
|
||||
# 使用 nvm 安装 Node 指定版本
|
||||
nvm install 0.10.48
|
|
@ -0,0 +1,10 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
echo -e "\n>>>>>>>>> install Node.js"
|
||||
|
||||
mkdir -p /opt/software/tomcat
|
||||
cd /opt/software/tomcat
|
||||
|
||||
version=8.5.27
|
||||
wget http://apache.fayea.com/tomcat/tomcat-8/v${version}/bin/apache-tomcat-${version}.tar.gz
|
||||
tar -zxvf apache-tomcat-${version}.tar.gz
|
Loading…
Reference in New Issue