2018-02-23 15:42:53 +08:00
|
|
|
|
#!/usr/bin/env bash
|
2018-02-01 16:34:02 +08:00
|
|
|
|
###################################################################################
|
2019-02-22 17:09:40 +08:00
|
|
|
|
# Linux CentOS 环境部署脚本
|
2018-02-02 15:28:50 +08:00
|
|
|
|
# Author: Zhang Peng
|
2018-02-01 16:34:02 +08:00
|
|
|
|
###################################################################################
|
|
|
|
|
|
2018-02-09 14:28:04 +08:00
|
|
|
|
function printHeadInfo() {
|
2018-02-01 16:34:02 +08:00
|
|
|
|
cat << EOF
|
|
|
|
|
***********************************************************************************
|
2019-02-22 17:09:40 +08:00
|
|
|
|
* Welcome to using the deployment script for CentOS.
|
2018-02-01 16:34:02 +08:00
|
|
|
|
* Author: Zhang Peng
|
|
|
|
|
***********************************************************************************
|
|
|
|
|
EOF
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-09 14:28:04 +08:00
|
|
|
|
function printFootInfo() {
|
2018-02-01 16:34:02 +08:00
|
|
|
|
cat << EOF
|
|
|
|
|
***********************************************************************************
|
|
|
|
|
* Deployment is over.
|
|
|
|
|
* Thank you for using!
|
|
|
|
|
***********************************************************************************
|
|
|
|
|
EOF
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function checkOsVersion(){
|
|
|
|
|
if(($1 == 1))
|
|
|
|
|
then
|
|
|
|
|
platform=`uname -i`
|
2019-03-01 10:36:45 +08:00
|
|
|
|
if [[ ${platform} != "x86_64" ]]; then
|
2018-02-01 16:34:02 +08:00
|
|
|
|
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)}'`
|
2019-03-01 10:36:45 +08:00
|
|
|
|
if [[ ${version} != 6 ]]; then
|
2018-02-01 16:34:02 +08:00
|
|
|
|
echo "this script is only for CentOS 6 !"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function showMenu() {
|
|
|
|
|
cat << EOF
|
|
|
|
|
|
2018-02-01 17:47:13 +08:00
|
|
|
|
=================================== Deploy Menu ===================================
|
2018-02-01 16:34:02 +08:00
|
|
|
|
【1 - System Environment】
|
2018-02-02 15:28:50 +08:00
|
|
|
|
[sys] initial system environment
|
|
|
|
|
[libs] install commonly libs
|
2018-02-01 17:36:03 +08:00
|
|
|
|
|
2018-02-01 16:34:02 +08:00
|
|
|
|
【2 - Common Tools】
|
|
|
|
|
[2 | tools] install all tools.
|
2018-02-02 15:28:50 +08:00
|
|
|
|
[git] install git [svn] install svn
|
2018-02-02 16:56:16 +08:00
|
|
|
|
[jdk8] install jdk8 [maven] install maven
|
|
|
|
|
[tomcat] install tomcat8 [nginx] install nginx
|
|
|
|
|
[nodejs] install node.js [elk] install elk
|
2018-02-27 10:31:35 +08:00
|
|
|
|
[redis] install redis [mongodb] install mongodb
|
2018-07-12 09:51:46 +08:00
|
|
|
|
[kafka] install kafka
|
2018-02-09 14:28:04 +08:00
|
|
|
|
|
|
|
|
|
【3 - Recommended Tools】
|
2018-02-09 13:55:54 +08:00
|
|
|
|
[sdk] install sdkman
|
2018-02-09 14:28:04 +08:00
|
|
|
|
[springboot] install spring boot cli
|
2018-02-01 16:34:02 +08:00
|
|
|
|
|
2018-02-01 17:47:13 +08:00
|
|
|
|
Press <CTRL-D> to exit
|
|
|
|
|
Please input key:
|
2018-02-01 16:34:02 +08:00
|
|
|
|
EOF
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function chooseOper() {
|
2018-02-09 14:28:04 +08:00
|
|
|
|
key=""
|
|
|
|
|
filepath=$(cd "$(dirname "$0")"; pwd)
|
2018-02-01 16:34:02 +08:00
|
|
|
|
while read key
|
|
|
|
|
do
|
|
|
|
|
case ${key} in
|
2018-02-09 14:28:04 +08:00
|
|
|
|
# 2 - System Environment
|
2018-02-09 13:55:54 +08:00
|
|
|
|
sys ) ${filepath}/sys/init.sh;;
|
|
|
|
|
libs ) ${filepath}/lib/install-libs.sh;;
|
2018-02-01 17:36:03 +08:00
|
|
|
|
|
2018-02-09 14:28:04 +08:00
|
|
|
|
# 2 - Common Tools
|
2019-02-22 11:34:34 +08:00
|
|
|
|
2 | tools ) ${filepath}/ops/service/install-all.sh;;
|
|
|
|
|
git ) ${filepath}/ops/service/git/install-git.sh;;
|
|
|
|
|
svn ) ${filepath}/ops/service/svn/install-svn.sh;;
|
|
|
|
|
jdk8 ) ${filepath}/ops/service/jdk/install-jdk8.sh;;
|
|
|
|
|
maven ) ${filepath}/ops/service/maven/install-maven3.sh;;
|
|
|
|
|
nginx ) ${filepath}/ops/service/nginx/install-nginx.sh;;
|
|
|
|
|
nodejs ) ${filepath}/ops/service/nodejs/install-nodejs.sh;;
|
|
|
|
|
tomcat ) ${filepath}/ops/service/tomcat/install-tomcat8.sh;;
|
|
|
|
|
elk ) ${filepath}/ops/service/elk/install-elk.sh;;
|
|
|
|
|
redis ) ${filepath}/ops/service/redis/install-redis.sh;;
|
|
|
|
|
mongodb ) ${filepath}/ops/service/mongodb/install-mongodb.sh;;
|
|
|
|
|
kafka ) ${filepath}/ops/service/kafka/install-kafka.sh;;
|
2018-02-09 14:28:04 +08:00
|
|
|
|
|
|
|
|
|
# 3 - Recommended Tools
|
2019-02-22 11:34:34 +08:00
|
|
|
|
sdk ) ${filepath}/ops/service/sdk/install-sdk.sh;;
|
|
|
|
|
springboot ) ${filepath}/ops/service/springboot/install-springboot.sh;;
|
2018-02-09 14:28:04 +08:00
|
|
|
|
|
2018-02-02 15:59:55 +08:00
|
|
|
|
* ) echo "${key} is invalid key";;
|
2018-02-01 16:34:02 +08:00
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
showMenu
|
|
|
|
|
done
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
######################################## MAIN ########################################
|
2018-02-09 14:28:04 +08:00
|
|
|
|
printHeadInfo
|
2018-02-01 16:34:02 +08:00
|
|
|
|
checkOsVersion 0
|
|
|
|
|
showMenu
|
|
|
|
|
chooseOper
|
2018-02-09 14:28:04 +08:00
|
|
|
|
printFootInfo
|