linux-tutorial/codes/deploy/main.sh

110 lines
3.2 KiB
Bash
Raw Normal View History

2018-02-23 15:42:53 +08:00
#!/usr/bin/env bash
2018-02-01 16:34:02 +08:00
###################################################################################
2018-02-02 15:28:50 +08:00
# Linux Centos 环境部署脚本
# Author: Zhang Peng
2018-02-01 16:34:02 +08:00
###################################################################################
function printHeadInfo() {
2018-02-01 16:34:02 +08:00
cat << EOF
***********************************************************************************
2018-02-02 15:28:50 +08:00
* Welcome to using the deployment script for Centos.
2018-02-01 16:34:02 +08:00
* Author: Zhang Peng
***********************************************************************************
EOF
}
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`
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
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
[redis] install redis [mongodb] install mongodb
2018-07-12 09:51:46 +08:00
[kafka] install kafka
【3 - Recommended Tools】
2018-02-09 13:55:54 +08:00
[sdk] install sdkman
[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() {
key=""
filepath=$(cd "$(dirname "$0")"; pwd)
2018-02-01 16:34:02 +08:00
while read key
do
case ${key} in
# 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
# 2 - Common Tools
2018-02-09 13:55:54 +08:00
2 | tools ) ${filepath}/tool/install-all.sh;;
git ) ${filepath}/tool/git/install-git.sh;;
svn ) ${filepath}/tool/svn/install-svn.sh;;
jdk8 ) ${filepath}/tool/jdk/install-jdk8.sh;;
maven ) ${filepath}/tool/maven/install-maven3.sh;;
nginx ) ${filepath}/tool/nginx/install-nginx.sh;;
nodejs ) ${filepath}/tool/nodejs/install-nodejs.sh;;
tomcat ) ${filepath}/tool/tomcat/install-tomcat8.sh;;
elk ) ${filepath}/tool/elk/install-elk.sh;;
2018-02-22 09:48:39 +08:00
redis ) ${filepath}/tool/redis/install-redis.sh;;
mongodb ) ${filepath}/tool/mongodb/install-mongodb.sh;;
2018-07-12 09:51:46 +08:00
kafka ) ${filepath}/tool/kafka/install-kafka.sh;;
# 3 - Recommended Tools
2018-02-09 13:55:54 +08:00
sdk ) ${filepath}/tool/sdk/install-sdk.sh;;
springboot ) ${filepath}/tool/springboot/install-springboot.sh;;
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 ########################################
printHeadInfo
2018-02-01 16:34:02 +08:00
checkOsVersion 0
showMenu
chooseOper
printFootInfo