|
| 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 |
0 commit comments