Skip to content

Commit 03fa4d3

Browse files
committed
✨ 添加环境部署脚本
1 parent 595ce49 commit 03fa4d3

18 files changed

Lines changed: 161 additions & 0 deletions

codes/deploy/main.sh

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#!/bin/bash
2+
###################################################################################
3+
# 环境部署脚本
4+
###################################################################################
5+
6+
function printBeginning() {
7+
cat << EOF
8+
***********************************************************************************
9+
* Welcome to using the deployment script for linux.
10+
* Author: Zhang Peng
11+
***********************************************************************************
12+
EOF
13+
}
14+
15+
function printEnding() {
16+
cat << EOF
17+
***********************************************************************************
18+
* Deployment is over.
19+
* Thank you for using!
20+
***********************************************************************************
21+
EOF
22+
}
23+
24+
function checkOsVersion(){
25+
if(($1 == 1))
26+
then
27+
platform=`uname -i`
28+
if [ $platform != "x86_64" ];then
29+
echo "this script is only for 64bit Operating System !"
30+
exit 1
31+
fi
32+
echo "the platform is ok"
33+
version=`lsb_release -r |awk '{print substr($2,1,1)}'`
34+
if [ $version != 6 ];then
35+
echo "this script is only for CentOS 6 !"
36+
exit 1
37+
fi
38+
fi
39+
}
40+
41+
42+
function showMenu() {
43+
cat << EOF
44+
45+
====================================== Deploy Menu ======================================
46+
【1 - System Environment】
47+
【2 - Common Tools】
48+
[2 | tools] install all tools.
49+
[2-1 | git] install git. [2-2 | jdk8] install jdk8.
50+
[2-3 | maven] install maven. [2-4 | nginx] install nginx.
51+
[2-5 | nodejs] install node.js. [2-6 | tomcat] install tomcat8.
52+
53+
按下 <CTRL-D> 退出。
54+
请输入 key:
55+
EOF
56+
}
57+
58+
key=""
59+
filepath=$(cd "$(dirname "$0")"; pwd)
60+
function chooseOper() {
61+
while read key
62+
do
63+
case ${key} in
64+
2 | tools) ${filepath}/tool/install-all.sh;;
65+
2-1 | git) ${filepath}/tool/git/install-git.sh;;
66+
2-2 | jdk8) ${filepath}/tool/jdk/install-jdk8.sh;;
67+
2-3 | maven) ${filepath}/tool/maven/install-maven.sh;;
68+
2-4 | nginx) ${filepath}/tool/nginx/install-nginx.sh;;
69+
2-5 | nodejs) ${filepath}/tool/nodejs/install-nodejs.sh;;
70+
2-6 | tomcat) ${filepath}/tool/tomcat/install-tomcat8.sh;;
71+
* ) echo "invalid key";;
72+
esac
73+
74+
showMenu
75+
done
76+
}
77+
78+
79+
80+
######################################## MAIN ########################################
81+
printBeginning
82+
checkOsVersion 0
83+
showMenu
84+
chooseOper
85+
printEnding
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
3+
echo -e "\n>>>>>>>>> install git"
4+
5+
yum -y install git

codes/deploy/tool/install-all.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
3+
echo -e "\n>>>>>>>>> install all tools"
4+
5+
./git/install-git.sh
6+
./jdk/install-jdk8.sh
7+
./maven/install-maven3.sh
8+
./nginx/install-nginx.sh
9+
./nodejs/install-nodejs.sh
10+
./tomcat/install-tomcat8.sh
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
echo -e "\n>>>>>>>>> install jdk8"
4+
5+
wget http://download.oracle.com/otn-pub/java/jdk/7u79-b15/jdk-7u79-linux-x64.rpm?AuthParam=1471671456_14c9442ffc64438c1b8fc83587ecdf47
6+
path = './jdk-7u79-linux-x64.rpm'
7+
8+
echo '正在安装JDK...'
9+
#update java
10+
for installedJava in $(rpm -qa |grep java);do
11+
rpm -e --nodeps $installedJava
12+
done
13+
rpm -ivh $path
14+
sunJava=$(ls /usr/java |grep jdk)
15+
if [ "$sunJava" != "" ];then
16+
cat >/etc/profile.d/java.sh<<EOF
17+
JAVA_HOME=/usr/java/$sunJava
18+
PATH=$JAVA_HOME/bin:\$PATH
19+
CLASSPATH=.:\$JAVA_HOME/lib/dt.jar:\$JAVA_HOME/lib/tools.jar
20+
export JAVA_HOME
21+
export PATH
22+
export CLASSPATH
23+
EOF
24+
chown root.root /etc/profile.d/java.sh
25+
fi
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
3+
echo -e "\n>>>>>>>>> install maven"
4+
5+
mkdir -p /opt/software/maven
6+
cd /opt/software/maven
7+
8+
version=3.5.2
9+
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
10+
tar -zxvf apache-maven-${version}-bin.tar.gz
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
3+
echo -e "\n>>>>>>>>> install nginx"
4+
5+
yum -y install make nginx.x86_64
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
3+
echo -e "\n>>>>>>>>> install Node.js"
4+
5+
# 安装 nvm
6+
rm -rf /home/admin/.nvm
7+
git clone https://github.com/creationix/nvm.git ~/.nvm && cd ~/.nvm
8+
source ~/.nvm/nvm.sh
9+
10+
# 使用 nvm 安装 Node 指定版本
11+
nvm install 0.10.48
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
3+
echo -e "\n>>>>>>>>> install Node.js"
4+
5+
mkdir -p /opt/software/tomcat
6+
cd /opt/software/tomcat
7+
8+
version=8.5.27
9+
wget http://apache.fayea.com/tomcat/tomcat-8/v${version}/bin/apache-tomcat-${version}.tar.gz
10+
tar -zxvf apache-tomcat-${version}.tar.gz
File renamed without changes.

0 commit comments

Comments
 (0)