最近因为公司项目需求,项目应用也比较多,所以编写一个shell函数多级菜单自动化部署各种应用的脚本:
本脚本实现的功能:
演示效果:
1、一级菜单
2、二级菜单
3、脚本参考
#!/bin/bash
#################################
#
# 单节点部署(centos 7)
# system time ntpdate(配置selinux,防火墙,时间同步,更改时区)
# Nginx 1.14.2
# redis 5.0.5
# rabbitmq 3.7.17
# dotnet 2.2.301
# MySQL 5.7.27
# pgsql 11.5
#################################
# 双节点部署(centos 7)
# keepalived负载均衡
# redis主从
# rabbitmq集群
# nginx负载均衡(代理两台web应用)
#################################
show_err() { echo -e "[ 33[31mFAILED 33[0m] $1";}
show_ok() { echo -e "[ 33[32m OK 33[0m] $1";}
show_info() { echo -e "[ 33[33mNOTICE 33[0m] $1";}
# must use root
[ $(id -u) != 0 ] && show_err 'The Script must be run as root.' && exit 1
# must use centos7
if [ -f /etc/centos-release ]; then
[ $(cat /etc/centos-release|awk '{print $4}'|cut -b1) != '7' ] && show_err 'The Script must be run as CentOS 7.' && exit 0
else
show_err 'The Script must be run as CentOS 7.' && exit 0
fi
#系统时间同步
time_ntpdate(){
echo ""
echo -e "