linux-tutorial/codes/deploy/main.sh

96 lines
2.6 KiB
Bash
Raw Normal View History

2018-02-01 16:34:02 +08:00
#!/bin/bash
###################################################################################
2018-02-02 15:28:50 +08:00
# Linux Centos 环境部署脚本
# Author: Zhang Peng
2018-02-01 16:34:02 +08:00
###################################################################################
function printBeginning() {
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 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
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-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
}
key=""
filepath=$(cd "$(dirname "$0")"; pwd)
function chooseOper() {
while read key
do
case ${key} in
2018-02-02 15:28:50 +08:00
sys) ${filepath}/sys/init.sh;;
libs) ${filepath}/lib/install-libs.sh;;
2018-02-01 17:36:03 +08:00
2018-02-01 16:34:02 +08:00
2 | tools) ${filepath}/tool/install-all.sh;;
2018-02-02 15:28:50 +08:00
git) ${filepath}/tool/git/install-git.sh;;
2018-02-02 16:56:16 +08:00
svn) ${filepath}/tool/svn/install-svn.sh;;
2018-02-02 15:28:50 +08:00
jdk8) ${filepath}/tool/jdk/install-jdk8.sh;;
maven) ${filepath}/tool/maven/install-maven.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-02 15:59:55 +08:00
* ) echo "${key} is invalid key";;
2018-02-01 16:34:02 +08:00
esac
showMenu
done
}
######################################## MAIN ########################################
printBeginning
checkOsVersion 0
showMenu
chooseOper
printEnding