首先要准备对应的RPM安装包,这里就不展示了,只显示脚本
#!/bin/bash
##################################
#Date:2023-9-8
#Author:lihua
#Version:2.0
#####################################
#--------------------------------------主菜单函数----------------------------------------------------------------------
show_menu(){
NORMAL=`echo "\033[m"`
MENU=`echo "\033[36m"` #Blue
NUMBER=`echo "\033[33m"` #yellow
FGRED=`echo "\033[41m"`
RED_TEXT=`echo "\033[31m"`
ENTER_LINE=`echo "\033[33m"`
echo -e -n "\e[36m \e[0m" ; echo -e "\t \e[47;34m Linux 自 动 化 脚 本 主 菜 单 \e[0m" ; echo -e "\e[36m \t \e[0m"
echo -e "\e[35m \t\t 作 者:lihua\t\t\t\t \e[0m"
echo -e "${MENU}************************************************************************${NORMAL}"
echo -e "${MENU}|\t${NUMBER} 1)${MENU} 关闭防火墙和系统参数优化操作 ${NORMAL}"
echo -e "${MENU}|\t${NUMBER} 2)${MENU} 安装Nginx_1.22 ${NORMAL}"
echo -e "${MENU}|\t${NUMBER} 3)${MENU} 安装Mysql_5.7 ${NORMAL}"
echo -e "${MENU}|\t${NUMBER} 4)${MENU} 安装Jdk_1.8 ${NORMAL}"
echo -e "${MENU}|\t${NUMBER} 5)${MENU} 安装Redis_5.0 ${NORMAL}"
echo -e "${MENU}|\t${NUMBER} 6)${MENU} 安装Minio ${NORMAL}"
echo -e "${MENU}|\t${NUMBER} 7)${MENU} 安装Rabbitmq_3.9 ${NORMAL}"
echo -e "${MENU}|\t${NUMBER} 8)${MENU} 安装Opencv_4.5.5 ${NORMAL}"
echo -e "${MENU}|\t${NUMBER} 9)${MENU} 安装Mariadb_10.0.33 ${NORMAL}"
echo -e "${MENU}|\t${NUMBER} 10)${MENU} 安装Elasticsearch_7.10.2 ${NORMAL}"
echo -e "${MENU}|\t${NUMBER} 20)${MENU} 安装Opencv_2.4.13 ${NUMBER}(*) ${NORMAL}"
echo -e "${MENU}|\t${NUMBER} 21)${MENU} 安装Gitlab_7.10.5 ${NUMBER}(*) ${NORMAL}"
echo -e "${MENU}|\t${NUMBER} 22)${MENU} 安装Mysql_8.0 ${NUMBER}(*) ${NORMAL}"
echo -e "${MENU}|\t${NUMBER} 30)${MENU} 卸载Mysql_5.7 ${NORMAL}"
echo -e "${MENU}|\t${NUMBER} 31)${MENU} 卸载Rabbitmq_3.9 ${NORMAL}"
echo -e "${MENU}|\t${NUMBER} 32)${MENU} 卸载Mariadb_10.0.33 ${NORMAL}"
echo -e "${MENU}|\t${NUMBER} q)${MENU} 请输入q或者Enter(回车键)将自动退出此脚本 ${NORMAL}"
echo -e "${MENU}|\t${NUMBER}DEL)${MENU} 如输入错误,请按住Ctrl+Backspace键进行删除操作 ${NORMAL}"
echo -e "${MENU}************************************************************************${NORMAL}"
echo -e "${ENTER_LINE}Please choose a menu option OR ${RED_TEXT}Enter(按回车键自动退出) to exit. ${NORMAL}"
read -p $'\033[42;34m请选择需要安装的序号:\033[0m' opt
}
#---------------------------显示序号数字函数-------------------------------------------------------------------------
function option_picked() {
COLOR='\033[01;31m' # bold red
RESET='\033[00;00m' # normal white
MESSAGE=${@:-"${RESET}Error: No message passed"}
echo -e "${COLOR}${MESSAGE}${RESET}"
}
#----------------------------目录全局函数------------------------------------------------------------------------------
CURRENT_DIR=$(cd $(dirname $0); pwd)
#----------------------------空格函数---------------------------------------------------------------------------
install_space(){
echo -e "\e[36m \t\t\t\t\t\t\t\t\t \e[0m"
echo -e "\e[36m \t\t\t\t\t\t\t\t\t \e[0m"
echo -e "\e[36m \t\t\t\t\t\t\t\t\t \e[0m"
}
#------------------------开启文件最大数函数--------------------------------------------------------------------------
open_wj(){
if ! grep "* soft nofile 65535" /etc/security/limits.conf &>/dev/null; then
cat >> /etc/security/limits.conf << EOF
* soft nproc 65535
* hard nproc 65535
* soft nofile 65535
* hard nofile 65535
EOF
fi
#system Maximum config
sys=`grep "fs.file-max = 65535" /etc/sysctl.conf | wc -l`
if [ "$sys" -eq "0" ]
then
cat >> /etc/sysctl.conf << EOF
fs.file-max = 65535
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_max_tw_buckets = 20480
net.ipv4.tcp_max_syn_backlog = 20480
net.core.netdev_max_backlog = 262144
net.ipv4.tcp_fin_timeout = 20
EOF
else
echo "系统参数已存在"
fi
sysctl -p
}
#-----------------------------node 1.关闭防火墙函数-----------------------------------------------------------------------
disable_firewalld(){
read -p $'请选择是否进行关闭防火墙和系统参数优化操作,选择yes会\e[31m【重启系统】\e[0m,让配置生效,谨慎操作!!(yes/no):' NUM1
case "$NUM1" in
"yes")
systemctl stop firewalld
systemctl disable firewalld && echo -e "\033[31m firewall已成功关闭 \033[0m"
iptables -F
iptables -X
iptables -Z
iptables-save &>/dev/null && echo -e "\033[31m iptables已成功关闭 \033[0m"
setenforce 0 &>/dev/null
sed -i s/SELINUX=enforcing/SELINUX=disabled/ /etc/selinux/config && echo -e "\033[31m selinux已成功关闭 \033[0m"
# 设置时区并同步时间
yum install -y ntpdate >/dev/null 2>&1
if ! crontab -l | grep ntpdate >/dev/null 2>&1 ; then
(echo "* 1 * * * ntpdate time.windows.com >/dev/null 2>&1"; crontab -l) | crontab
fi
# 历史命令显示操作时间
if ! grep HISTTIMEFORMAT /etc/bashrc; then
echo 'export HISTTIMEFORMAT="%F %T `whoami` "' >> /etc/bashrc
fi
# 设置最大打开文件数
open_wj
echo -e "\033[32m 防火墙和系统参数优化操作已完成,正在重启系统,请等待.............. \033[0m"
reboot
;;
"no")
echo -e "\033[31m 很遗憾您拒绝了我,再见!\033[0m"
;;
*)
echo -e "\033[31m 不明白您的意思;再运行一次吧!\033[0m"
esac
}
#-------------------------------node 2.安装nginx函数-------------------------------------------------
install_nginx(){
cp $CURRENT_DIR/libpcre2-8.so.0.5.0 /usr/lib64/
cd /usr/lib64/
ln -s libpcre2-8.so.0.5.0 libpcre2-8.so.0
rpm -ivh $CURRENT_DIR/openssl-libs-1.0.2k-19.el7.x86_64.rpm --force
rpm -ivh $CURRENT_DIR/nginx-1.22.0-1.el7.ngx.x86_64.rpm --nodeps --force
mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf_back
cp $CURRENT_DIR/nginx.conf $CURRENT_DIR/proxy-file.conf /etc/nginx
/usr/sbin/nginx
if [ "$?" -eq 0 ];then
action "恭喜你,成功安装Nginx并将服务加入开机自启动,配置文件目录:/etc/nginx!!!" /bin/true && systemctl enable nginx
else
action "对不起,安装Nginx失败! ! !" /bin/false
exit 1
fi
}
#------------------------------node 3.安装mysql函数----------------------------------------------------------------------------
install_mysql(){
mariadb_rpm_list=`rpm -qa |grep mariadb`
if [ -n "$mariadb_rpm_list" ];then
echo "mariadb检查结果:系统已安装mariadb,需先卸载"
read -p "是否卸载mariadb?(Y/N):" choose_Unmariadb
if [ "$choose_Unmariadb" == 'Y' ] || [ "$choose_Unmariadb" == 'y' ] ;then
echo "开始卸载mariadb..."
rpm -qa |grep mariadb |xargs rpm -e --nodeps
sleep 2
echo -e "\033[31m mariadb卸载完成!\033[0m"
else
exit 0
fi
else
echo -e "\033[31m mariadb检查结果:系统未安装mariadb.\033[0m"
fi
echo -e "\033[32m 安装MySQL5.7.36 软件包 \033[0m"
tar xvf $CURRENT_DIR/mysql-5.7.36-1.el7.x86_64.rpm-bundle.tar >/dev/null 2>&1
rpm -ivh $CURRENT_DIR/mysql-community-common-5.7.36-1.el7.x86_64.rpm
rpm -ivh $CURRENT_DIR/mysql-community-libs-5.7.36-1.el7.x86_64.rpm
rpm -ivh $CURRENT_DIR/mysql-community-libs-compat-5.7.36-1.el7.x86_64.rpm
rpm -ivh $CURRENT_DIR/mysql-community-client-5.7.36-1.el7.x86_64.rpm
rpm -ivh $CURRENT_DIR/mysql-community-devel-5.7.36-1.el7.x86_64.rpm
rpm -ivh $CURRENT_DIR/mysql-community-server-5.7.36-1.el7.x86_64.rpm --force --nodeps
mv /etc/my.cnf /etc/my.cnf.back
cat > /etc/my.cnf << EOF
[client]
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
port = 3306
server_id = 1
log_slave-updates = true
log-bin = mysql-bin
log_bin_trust_function_creators = 1
user = mysql
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_general_ci
init_connect='SET NAMES utf8mb4'
lower_case_table_names = 1
sql_mode = STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
symbolic-links = 0
log-error = /var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
default_password_lifetime = 0
EOF
open_wj
echo -e "\033[32m 启动MySQL服务 \033[0m"
systemctl start mysqld
if [ "$?" -eq 0 ];then
action "恭喜你,成功安装Mysql并将服务加入开机自启动!!!" /bin/true && systemctl enable mysqld
else
action "对不起,安装Mysql失败! ! !" /bin/false
exit 1
fi
echo -e "\033[32m 2、修改mysql密码 \033[0m"
initpasswd=`cat /var/log/mysqld.log |grep root@localhost |awk '{print $NF}'` # 初始密码
echo "MySQL的初始密码是:$initpasswd"
read -p "请输入您要设置MySQL的root用户密码:" passwd
export MYSQL_PWD=$initpasswd #解决mysql>5.6会提示密码安全问题
mysql -uroot -p${initpasswd} --connect-expired-password -e "set global validate_password_policy=LOW;set global validate_password_length=6;alter user 'root'@'localhost' identified by \"$passwd\";use mysql;update user set host = '%' where user ='root';flush privileges;"
if [ "$?" -eq 0 ];then
action "MySQL数据库安装成功,密码为:$passwd" /bin/true
else
action "MySQL数据库安装失败密码初始化失败!" /bin/false
exit 1
fi
echo -e "\033[32m 3、mysql使用及目录 \033[0m"
mysql -uroot -p$passwd -e "show databases;"
if [[ $? -eq 0 ]]; then
echo -e "\033[32m MySQL5.7安装完成,数据目录: /var/lib/mysql 请使用: mysql -uroot -p$passwd 命令进行连接\033[0m"
else
echo -e "\033[5;41;32m MySql5.7安装失败,请排查错误信息。重新安装请输入【30】进行卸载后,重新执行脚本安装 \033[1;m"
fi
}
#---------------------------node 4.安装jdk函数--------------------------------------------------------------------------
install_jdk(){
jdk_rpm_list=`rpm -qa |grep java`
if [ -n "$jdk_rpm_list" ]; then
echo -e "\033[32m jdk检查结果:系统已安装openjdk,需先卸载,已安装的openjdk如下:\033[0m"
rpm -qa | grep java | tee
read -p "是否卸载已安装的openjdk?(Y/N):" choose_Unrabbitmq
if [ "$choose_Unrabbitmq" == 'Y' ] || [ "$choose_Unrabbitmq" == 'y' ];then
echo "开始卸载openjdk..."
rpm -qa | grep -i java | xargs -n1 rpm -e --nodeps
sleep 2
echo "openjdk卸载完成!!"
else
exit 0
fi
else
echo "openjdk检查结果:系统未安装Openjdk."
fi
source /etc/profile
jdkv=`echo $(java -version 2>&1 |awk 'NR==1{gsub(/"/,"");print $3}')|awk -F'_' '{print $1}'`
if [ "$jdkv" == "1.8.0" ]
then
echo -e "\033[32m 系统已存在JDK版本1.8,不在重复安装!\033[0m"
else
echo -e "\033[32m 未检测到JDK1.8,稍后将继续安装,请等待........\033[0m"
echo -e "检查JDK是否配置环境,删除原环境........"
jdk1=$(grep -n "export JAVA_HOME=.*" /etc/profile | cut -f1 -d':')
if [ -n "$jdk1" ];then
echo "JAVA_HOME已配置,删除内容"
sed -i "${jdk1}d" /etc/profile
fi
jdk2=$(grep -n "export CLASSPATH=.*\$JAVA_HOME.*" /etc/profile | cut -f1 -d':')
if [ -n "$jdk2" ];then
echo "CLASSPATH路径已配置,删除内容"
sed -i "${jdk2}d" /etc/profile
fi
jdk3=$(grep -n "export PATH=.*\$JAVA_HOME.*" /etc/profile | cut -f1 -d':')
if [ -n "$jdk3" ];then
echo "PATH-JAVA路径已配置,删除内容"
sed -i "${jdk3}d" /etc/profile
fi
jdk=true
if [ "$jdk" = true ];then
tar -zxf jdk-8u161-linux-x64.tar.gz -C /usr/local
mv /usr/local/jdk1.8.0_161 /usr/local/jdk180
sed -i '73a\export PATH=$PATH:$JAVA_HOME/bin' /etc/profile
sed -i '73a\export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar' /etc/profile
sed -i '73a\export JAVA_HOME=/usr/local/jdk180' /etc/profile
sed -i '73a\# JAVA_HOME' /etc/profile
fi
source /etc/profile
java -version
if [ "$?" -eq 0 ];then
action "恭喜你,成功安装JDK1.8!!!" /bin/true
echo -e "\033[32m 因使用脚本安装,本机使用时需要在执行一下 【source /etc/profile】 命令 \033[0m"
else
action "对不起,安装JDK失败! ! !" /bin/false
exit 1
fi
fi
}
#---------------------------node 5.安装redis函数---------------------------------------------------------------
install_redis(){
rpm -ivh $CURRENT_DIR/redis-5.0.14-1.el7.remi.x86_64.rpm
sed -i "s/bind 127.0.0.1/bind 0.0.0.0/g" /etc/redis.conf
sed -i "s/protected-mode yes/protected-mode no/g" /etc/redis.conf
sed -i "s/daemonize no/daemonize yes/g" /etc/redis.conf
sed -i 's/appendonly no/appendonly yes/g' /etc/redis.conf
echo "vm.overcommit_memory=1" >> /etc/sysctl.conf
echo never > /sys/kernel/mm/transparent_hugepage/enabled
sysctl -p
cat >> /etc/systemd/system/redis.service << EOF
[Unit]
Description=redis-server
After=network.target
[Service]
User=redis
Group=redis
Type=forking
ExecStart=/usr/bin/redis-server /etc/redis.conf
PrivateTmp=true
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl start redis
if [ "$?" -eq 0 ];then
action "恭喜你,成功安装REDIS并将服务加入开机自启动!!!" /bin/true && systemctl enable redis
else
action "对不起,安装REDIS失败! ! !" /bin/false
exit 1
fi
}
#----------------------------------node 6.安装minio函数--------------------------------------------------------
install_minio(){
rpm -ivh $CURRENT_DIR/minio-20230711212934.0.0.x86_64.rpm
systemctl enable minio
sed -i "s/User=minio-user/User=root/g" /usr/lib/systemd/system/minio.service
sed -i "s/Group=minio-user/Group=root/g" /usr/lib/systemd/system/minio.service
cp minio /etc/default
echo -e "\033[32m minio配置修改 \033[0m"
read -p "请输入minio存储路径目录:" miniodir
mkdir -p $miniodir
mdir=`cat /etc/default/minio| grep -w "MINIO_VOLUMES" | awk -F'=' '{print $2}'| sed 's/\"//g'`
sed -i "s#${mdir}#${miniodir}#g" /etc/default/minio
read -p "请输入web界面登陆用户名:" miniouser
muser=`cat /etc/default/minio| grep -w "MINIO_ACCESS_KEY" | awk -F'=' '{print $2}'| sed 's/\"//g'`
sed -i "s/${muser}/${miniouser}/g" /etc/default/minio
read -p "请输入web界面登陆密码:" miniopasswd
mmpasswd=`cat /etc/default/minio| grep -w "MINIO_SECRET_KEY" | awk -F'=' '{print $2}'| sed 's/\"//g'`
sed -i "s/${mmpasswd}/${miniopasswd}/g" /etc/default/minio
systemctl daemon-reload
service minio start
if [ "$?" -eq 0 ];then
action "恭喜你,成功安装MINIO并将服务加入开机自启动!!!" /bin/true
else
action "对不起,安装MINIO失败! ! !" /bin/false
exit 1
fi
echo -e "\033[32m minio使用及目录 \033[0m"
IP=`ip addr | grep "inet" | grep "brd"| awk '{print $2}'| awk -F'/' '{print $1}'`
user=`cat /etc/default/minio | grep "ACCESS"| awk -F'=' '{print $2}' |sed 's/\"//g'`
passwd=`cat /etc/default/minio | grep "SECRET"| awk -F'=' '{print $2}' |sed 's/\"//g'`
if [[ $? -eq 0 ]]; then
echo -e "\033[32m MINIO安装完成,数据目录: $miniodir 请使用: $IP:9001 进行web页面登录;登录用户名为:$user,密码为:$passwd \033[0m"
else
echo -e "\033[5;41;32m MINIO安装失败,请排查错误信息。重新安装请卸载后,重新执行脚本安装 \033[1;m"
fi
}
#------------------------------------node 7.安装rabbitmq------------------------------------------------------------------
install_rabbitmq(){
rpm -ivh $CURRENT_DIR/erlang-23.3.4.11-1.el7.x86_64.rpm
rpm -ivh $CURRENT_DIR/rabbitmq-server-3.9.13-1.el7.noarch.rpm
service rabbitmq-server start
if [ "$?" -eq 0 ];then
action "恭喜你,成功安装rabbitmq!!!" /bin/true && systemctl enable rabbitmq-server
else
action "对不起,安装rabbitmq失败! ! !" /bin/false
exit 1
fi
echo -e "\033[32m 2、开启图形化管理界面 \033[0m"
rabbitmq-plugins enable rabbitmq_management
if [ "$?" -eq 0 ];then
action "恭喜你,开启rabbitmq图形化管理界面成功!!!" /bin/true
else
action "对不起,开启rabbitmq图形化管理界面失败! ! !" /bin/false
exit 1
fi
echo -e "\033[32m 3、设置图形化管理界面用户名和密码 \033[0m"
read -p "请输入rabbitmq图形化管理界面用户名:" USER
read -p "请输入rabbitmq图形化管理界面密码:" PASSWD
IP=`ip addr | grep "inet" | grep "brd"| awk '{print $2}'| awk -F'/' '{print $1}'`
rabbitmqctl add_user $USER $PASSWD
rabbitmqctl set_user_tags $USER administrator
rabbitmqctl set_permissions -p "/" $USER ".*" ".*" ".*"
if [[ $? -eq 0 ]]; then
echo -e "\033[32m rabbitmq安装完成; 请使用: $IP:15672 进行web页面登录;登录用户名为:$USER,密码为:$PASSWD \033[0m"
else
echo -e "\033[5;41;32m rabbitmq安装失败,请排查错误信息。重新安装,请选择【31】卸载后,重新执行脚本安装 \033[1;m"
fi
}
#-------------------------------node 8.安装opencv_4.5.5--------------------------------------------------------------------
install_opencv_4.5.5(){
tar xvf $CURRENT_DIR/opencv-install.tar >/dev/null 2>&1
mv $CURRENT_DIR/opencv-install /opt/
echo '1、开始安装JDK'
install_jdk
echo '2、开始安装cmake和opencv所需依赖'
rpm -Uvh --force --nodeps /opt/opencv-install/rpm/*rpm
echo '3、开始安装cmake'
tar -zxvf /opt/opencv-install/tar/cmake-3.6.2.tar.gz -C /usr/local
cd /usr/local/cmake-3.6.2
./bootstrap && make -j4
if [ "$?" -eq 0 ];then
action "cmake编译成功,将继续安装....." /bin/true
else
action "对不起,编译cmake失败! ! !" /bin/false
exit 1
fi
make install
echo '4、开始安装ffmpeg'
tar -zxvf /opt/opencv-install/tar/ffmpeg-4.2.2.tar.gz -C /usr/local/
mv /usr/local/ffmpeg-4.2.2 /usr/local/ffmpeg
cd /usr/local/ffmpeg
./configure --enable-shared --enable-pic --enable-static --disable-yasm --prefix=/usr/local/ffmpeg
make
if [ "$?" -eq 0 ];then
action "ffmpeg编译成功,将继续安装....." /bin/true
else
action "对不起,编译ffmpeg失败! ! !" /bin/false
exit 1
fi
make install
echo -e 'include ld.so.conf.d/*.conf\n/usr/local/ffmpeg/lib/' >> /etc/ld.so.conf.d/ffmpeg.conf
ldconfig
echo -e '\nexport PATH=$PATH:/usr/local/ffmpeg/bin' >> /etc/profile
source /etc/profile
cp /usr/local/ffmpeg/lib/pkgconfig/* /usr/share/pkgconfig
echo '5、开始编译opencv-4.5.5'
mv /opt/opencv-install/opencv /usr/local/
cd /usr/local/opencv/build/
/usr/local/bin/cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local -D OPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modules/ -D WITH_FFMPEG=ON -D OPENCV_GENERATE_PKGCONFIG=ON ..
make -j4
if [ "$?" -eq 0 ];then
action "opencv编译成功,将继续安装....." /bin/true
else
action "对不起,编译opencv失败! ! !" /bin/false
exit 1
fi
make install
ln -s /usr/local/lib64/pkgconfig/opencv4.pc /usr/share/pkgconfig/
ldconfig
echo -e '\nexport PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib64/pkgconfig\nexport LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib64' >> /etc/profile
source /etc/profile
cp /usr/local/lib64/pkgconfig/opencv4.pc /usr/lib/pkgconfig
ldconfig
cp /usr/local/opencv/build/lib/libopencv_java455.so /usr/lib
echo -e "\033[32m 检查Opencv4.5.5所依赖的环境是否OK,请稍后..... \033[0m"
java -version
echo -e '\n'
ffmpeg -version
echo -e '\nopencv version '
pkg-config --modversion opencv4
if [ "$?" -eq 0 ];then
action "恭喜你,成功安装Opencv_4.5.5!!!" /bin/true
else
action "对不起,安装Opencv_4.5.5失败! ! !" /bin/false
exit 1
fi
}
#-----------------------------------node 9.安装mariadb10.0.33--------------------------------------------------------------------
install_mariadb(){
tar -xzvf $CURRENT_DIR/mariadb-10.0.33-linux-x86_64.tar.gz > /dev/null 2>&1
mv $CURRENT_DIR/mariadb-10.0.33-linux-x86_64 /usr/local/mariadb-10.0.33
useradd -s /sbin/nologin -M mysql
cd /usr/local/mariadb-10.0.33
./scripts/mysql_install_db --user=mysql
if [ "$?" -eq 0 ];then
action "mariadb初始化成功,将继续安装....." /bin/true
else
action "对不起,mariadb初始化失败! ! !" /bin/false
exit 1
fi
sleep 2
mv /etc/my.cnf /etc/my.cnf.bak
cp support-files/my-innodb-heavy-4G.cnf /etc/my.cnf
sed -i '45i basedir=/usr/local/mariadb-10.0.33' /etc/my.cnf
sed -i '46i datadir=/var/lib/mysql' /etc/my.cnf
open_wj
cp support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
chkconfig --add mysqld
/etc/init.d/mysqld start
if [ "$?" -eq 0 ];then
action "mariadb服务启动成功....." /bin/true
else
action "对不起,mariadb服务启动失败! ! !" /bin/false
exit 1
fi
echo 'PATH=$PATH:/usr/local/mariadb-10.0.33/bin' >> /etc/profile
source /etc/profile
echo -e "\033[32m 2、修改mariadb密码和权限 \033[0m"
read -p "请输入您要设置Mariadb的root用户密码:" passwd
/usr/local/mariadb-10.0.33/bin/mysqladmin -u root password $passwd
/usr/local/mariadb-10.0.33/bin/mysql -uroot -p$passwd -e "grant all privileges on *.* to root@'localhost' identified by '$passwd' with grant option;"
/usr/local/mariadb-10.0.33/bin/mysql -uroot -p$passwd -e "grant all privileges on *.* to root@'%' identified by '$passwd' with grant option;"
/usr/local/mariadb-10.0.33/bin/mysql -uroot -p$passwd -e "FLUSH PRIVILEGES;"
/usr/local/mariadb-10.0.33/bin/mysql -uroot -p$passwd -e "CREATE DATABASE gitlabhq_production;"
echo -e "\033[32m 3、Mariadb使用及目录 \033[0m"
mysql -uroot -p$passwd -e "show databases;"
if [[ $? -eq 0 ]]; then
echo -e "\033[32m Mariadb安装完成,数据目录: /var/lib/mysql 请使用: mysql -uroot -p$passwd 命令进行连接\033[0m"
else
echo -e "\033[5;41;32m Mariadb安装失败,请排查错误信息。重新安装请输入【32】进行卸载后,重新执行脚本安装 \033[1;m"
fi
}
#-----------------------------------node 10.安装elasticsearch7.10.2--------------------------------------------------------------------
install_elasticsearch(){
rpm -ivh $CURRENT_DIR/elasticsearch-7.10.2-x86_64.rpm
#单独创建目录用于存放elasticsearch数据
mkdir -p /home/elasticsearch/data
mkdir -p /home/elasticsearch/logs
chown -R elasticsearch:elasticsearch /home/elasticsearch
cp /etc/elasticsearch/elasticsearch.yml /etc/elasticsearch/elasticsearch.yml_default
#修改elasticsearch相关配置文件
sed -i "s@#cluster.name: [email protected]: graylog@g" /etc/elasticsearch/elasticsearch.yml
sed -i "s#path.data: /var/lib/elasticsearch#path.data: /home/elasticsearch/data#g" /etc/elasticsearch/elasticsearch.yml
sed -i "s#path.logs: /var/log/elasticsearch#path.logs: /home/elasticsearch/logs#g" /etc/elasticsearch/elasticsearch.yml
#echo "action.auto_create_index: false" >> /etc/elasticsearch/elasticsearch.yml
#修改JVM内存大小
sed -i "s/-Xms1g/-Xms1g/g" /etc/elasticsearch/jvm.options
sed -i "s/-Xmx1g/-Xmx1g/g" /etc/elasticsearch/jvm.options
open_wj
#启动elasticsearch服务
systemctl daemon-reload
systemctl enable elasticsearch.service
systemctl start elasticsearch.service
if [[ $? -eq 0 ]]; then
echo -e "\033[32m Elasticsearch安装完成,配置只开放了本机,如需对外请修改配置\033[0m"
else
echo -e "\033[5;41;32m Elasticsearch安装失败,请排查错误信息。重新安装请进行卸载后,重新执行脚本安装 \033[1;m"
fi
curl -s -XGET 'http://127.0.0.1:9200/_cluster/health?pretty=true'
curl -s -XGET 'http://127.0.0.1:9200/_cat/nodes?v'
}
#---------------------------------node 20.安装opencv2.4.13函数-----------------------------------------------------------
install_opencv_2.4.13(){
yum install -y unzip >/dev/null 2>&1
unzip $CURRENT_DIR/opencv-2.4.13.zip >/dev/null 2>&1
mv $CURRENT_DIR/opencv-2.4.13 /usr/local/src
yum install cmake gcc gcc-c++ gtk+-devel gimp-devel gimp-devel-tools gimp-help-browser zlib-devel libtiff-devel libjpeg-devel libpng-devel gstreamer-devel libavc1394-devel libraw1394-devel libdc1394-devel jasper-devel jasper-utils swig python libtool nasm build-essential ant make ffmpeg -y
echo -e "\033[32m 开始安装JDK,请稍等...... \033[0m"
install_jdk
cd /usr/local/src/opencv-2.4.13
cd build
rm -rf *
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
make -j8
if [ "$?" -eq 0 ];then
action "第一次编译成功,将继续安装....." /bin/true
else
action "对不起,第一次编译opencv失败! ! !" /bin/false
exit 1
fi
make install
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -DBUILD_TESTS=OFF ..
make -j8
if [ "$?" -eq 0 ];then
action "第二次编译成功,将继续安装....." /bin/true
else
action "对不起,第二次编译opencv失败! ! !" /bin/false
exit 1
fi
make install
sleep 2
/usr/bin/cp /usr/local/share/OpenCV/java/libopencv_java2413.so /usr/lib
if [ "$?" -eq 0 ];then
action "恭喜你,成功安装Opencv_2.4.13!!!" /bin/true
else
action "对不起,安装Opencv_2.4.13失败! ! !" /bin/false
exit 1
fi
}
#---------------------------------------------gitlab7.10.5初始化函数---------------------------------------------------
init_gitlab(){
echo -e "\033[34m 4、Gitlab即将初始化,初始化提供线上和线下,2种方式进行\033[0m"
echo -e "\033[32m(1)线上方式:一路选择(Y)\033[0m"
echo -e "\033[32m(2)线下方式:\e[31m先选择(N),然后请修改/etc/gitlab/gitlab.rb文件对应的配置项,在初始化这一步再次执行(Y-N)\e[0m 操作\033[0m"
read -p "是否进行Gitlab初始化动作?(Y/N):" choose_gitlab
if [ "$choose_gitlab" == 'Y' ] || [ "$choose_gitlab" == 'y' ];then
echo -e "\033[32m 开始初始化Gitlab,请等待...\033[0m"
echo -e "${NUMBER}说明:(1)线上初始化为:直接输入配置项,进行更改配置操作${NORMAL}"
echo -e "${NUMBER} (2)线下初始化为:在上一步选择(N)直接退出安装脚本后,进行了线下修改配置项,再次执行初始化操作,选择线下初始化(N)${NORMAL}"
read -p "请选择进行线上初始化(Y)OR 线下初始化(N)?(Y/N):" choose_gitlab_init
if [ "$choose_gitlab_init" == 'Y' ] || [ "$choose_gitlab_init" == 'y' ];then
#####################################线上初始化########################################################################
echo -e "\033[32m 请根据提示输入配置项,如输入错误请按住\033[31m Ctrl+Backspace \033[0m 进行删除操作!.......\033[0m"
w=`grep -w "external_url" /etc/gitlab/gitlab.rb | sed '1d' | awk -F' ' '{print $2}' | cut -d"'" -f2 | awk -F'/' '{print $3}'`
read -p $'请输入gitlab的\033[31mIP\033[0m地址: ' gitlabip
sed -i "s/${w}/${gitlabip}/g" /etc/gitlab/gitlab.rb
n=`grep -w "db_password" /etc/gitlab/gitlab.rb | awk -F'=' '{print $2}' | sed 's/\"//g' | sed 's/^[ ]*//g' | sed '1d' | sed '2d'`
read -p $'请输入数据库\033[31mmariadb密码\033[0m: ' gitlabpass
sed -i "s/${n}/${gitlabpass}/g" /etc/gitlab/gitlab.rb
m=`grep -n "git_data_dir" /etc/gitlab/gitlab.rb | awk -F' ' '{print $3}' | sed 's/\"//g'`
read -p $'请输入\033[31m数据存储路\033[0m径地址,尽量使用容量大的磁盘,目录不存在时会自动创建: ' gitlabdir
sed -i "s#${m}#${gitlabdir}#g" /etc/gitlab/gitlab.rb
q=`grep -n "backup_path" /etc/gitlab/gitlab.rb | awk -F'=' '{print $2}' | sed 's/\"//g' | sed 's/^[ ]*//g'`
read -p $'请输入\033[31m数据备份\033[0m路径地址,尽量使用容量大的磁盘,目录不存在时会自动创建: ' gitlabback
sed -i "s#${q}#${gitlabback}#g" /etc/gitlab/gitlab.rb
gitlab-ctl reconfigure
if [ "$?" -eq 0 ];then
action "gitlab初始化成功,将继续安装....." /bin/true
else
action "对不起,gitlab初始化失败! ,请检查错误后再次初始化" /bin/false
exit 1
fi
echo -e "\033[32m 开始初始化数据库,请等待......\033[0m"
gitlab-rake gitlab:setup
if [ "$?" -eq 0 ];then
action "数据库初始化成功,将继续安装....." /bin/true
else
action "对不起,数据库初始化失败! ,请检查错误后再次初始化" /bin/false
exit 1
fi
echo -e "\033[32m 开始初始化检查,请等待.......\033[0m"
gitlab-rake gitlab:check
if [[ $? -eq 0 ]]; then
echo -e "\033[32m初始化检查成功,正在重启服务,请等待..... \033[0m"
else
echo -e "\033[5;41;32m 对不起,初始化失败! ,请检查错误后再次初始化 \033[1;m"
fi
else
######################################线下初始化##########################################################
gitlab-ctl reconfigure
if [ "$?" -eq 0 ];then
action "gitlab初始化成功,将继续安装....." /bin/true
else
action "对不起,gitlab初始化失败! ,请检查错误后再次初始化" /bin/false
exit 1
fi
echo -e "\033[32m 开始初始化数据库,请等待......\033[0m"
gitlab-rake gitlab:setup
if [ "$?" -eq 0 ];then
action "数据库初始化成功,将继续安装....." /bin/true
else
action "对不起,数据库初始化失败! ,请检查错误后再次初始化" /bin/false
exit 1
fi
echo -e "\033[32m 开始初始化检查,请等待.......\033[0m"
gitlab-rake gitlab:check
if [[ $? -eq 0 ]]; then
echo -e "\033[32m初始化检查成功,正在重启服务,请等待..... \033[0m"
else
echo -e "\033[5;41;32m 对不起,初始化失败! ,请检查错误后再次初始化 \033[1;m"
fi
fi
else
exit 0
fi
}
#---------------------------------node 21.安装gitlab7.10.5函数-----------------------------------------------------------
install_gitlab(){
echo -e "\033[34m 1、检查是否安装redis \033[0m"
redis_list=`ps axu |grep redis| grep -v "grep"`
if [ -n "$redis_list" ]; then
echo -e "\033[32m redis检查结果:系统已安装redis,直接跳过安装redis\033[0m"
else
install_redis
fi
sleep 2
echo -e "\033[34m 2、检查是否安装mariadb \033[0m"
mysql_list=`ps axu |grep mariadb | grep -v "grep"`
if [ -n "$mysql_list" ]; then
echo -e "\033[32m mariadb检查结果:系统已安装mariadb,直接跳过安装mariadb\033[0m"
else
install_mariadb
fi
sleep 2
echo -e "\033[34m 3、Gitlab组件包已安装成功,下一步进行gitlab依赖安装,因脚本使用80端口,确保80端口没被占用,请等待...\033[0m"
read -p "是否进行Gitlab依赖安装,初次安装请选择Y,如之前安装过就无须再次安装了,直接选择(N)进行初始化操作?(Y/N):" choose_gitlab_qianzhi
if [ "$choose_gitlab_qianzhi" == 'Y' ] || [ "$choose_gitlab_qianzhi" == 'y' ];then
echo -e "\033[32m 开始Gitlab依赖安装,因依赖网络速度,时间较长,并保证此机器能联网使用,请耐心等待...\033[0m"
yum install -y gcc ruby-devel mysql-devel >/dev/null 2>&1
yum install -y $CURRENT_DIR/gitlab-ce-7.10.5~omnibus-1.x86_64.rpm
gem sources --remove https://rubygems.org/
gem sources -a https://mirrors.cloud.tencent.com/rubygems/
cd /opt/gitlab/embedded/bin/
./gem install -i /opt/gitlab/embedded/service/gem/ruby/2.1.0 mysql2
./gem install -i/opt/gitlab/embedded/service/gem/ruby/2.1.0 mysql2 -v "0.3.16"
sed -i 's/BUNDLE_WITHOUT: development:test:mysql/BUNDLE_WITHOUT: development:test:postgres/g' /opt/gitlab/embedded/service/gitlab-rails/.bundle/config
mv /etc/gitlab/gitlab.rb /etc/gitlab/gitlab.rb.back
cp $CURRENT_DIR/gitlab.rb /etc/gitlab/gitlab.rb
init_gitlab
else
init_gitlab
fi
gitlab-ctl stop
gitlab-ctl start
IP=`ip addr | grep "inet" | grep "brd"| awk '{print $2}'| awk -F'/' '{print $1}'`
if [[ $? -eq 0 ]]; then
echo -e "\033[32mgitlab安装成功..... 登录地址为:http://$IP; 管理员用户名和密码为:root/5iveL!fe \033[0m"
else
echo -e "\033[5;41;32m 对不起,gitlab安装失败 ,请检查错误后再次安装 \033[1;m"
fi
}
#-----------------------------------node 22.安装mysql8.0.25--------------------------------------------------------------------
install_mysql8(){
yum install net-tools vim-en* -y >/dev/null 2>&1
echo -e "检查是否安装mariadb"
rpm -qa|grep mariadb
if [ $? -eq 0 ];then
rpm -e --nodeps mariadb-libs
echo "----- 成功卸载mariadb-libs,脚本继续执行 -----"
else
echo "----- mariadb-libs不存在,脚本继续执行 -----"
fi
tar xvf mysql-8.0.25-1.el7.x86_64.rpm-bundle.tar > /dev/null 2>&1
#开始安装mysql
rpm -ivh $CURRENT_DIR/mysql-community-common-8.0.25-1.el7.x86_64.rpm
rpm -ivh $CURRENT_DIR/mysql-community-client-plugins-8.0.25-1.el7.x86_64.rpm
rpm -ivh $CURRENT_DIR/mysql-community-libs*
rpm -ivh $CURRENT_DIR/mysql-community-client-8.0.25-1.el7.x86_64.rpm
rpm -ivh $CURRENT_DIR/mysql-community-server-8.0.25-1.el7.x86_64.rpm
mv /etc/my.cnf /etc/my.cnf.back
cat > /etc/my.cnf << EOF
[client]
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
port = 3306
server_id = 1
log_slave-updates = true
log-bin = mysql-bin
log_bin_trust_function_creators = 1
user = mysql
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_general_ci
init_connect='SET NAMES utf8mb4'
lower_case_table_names = 1
max_connections=200
default-storage-engine=INNODB
default_authentication_plugin=mysql_native_password
default-time_zone='+8:00'
lower_case_table_names=1
log_timestamps = SYSTEM
log_bin_trust_function_creators = on
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
symbolic-links = 0
log-error = /var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
default_password_lifetime = 0
EOF
open_wj
#启动mysql服务,不然会获取不到mysql默认密码
echo -e "\033[32m 启动MySQL服务 \033[0m"
systemctl start mysqld
if [ "$?" -eq 0 ];then
action "恭喜你,成功安装Mysql!!!" /bin/true && systemctl enable mysqld
else
action "对不起,安装Mysql失败! ! !" /bin/false
exit 1
fi
echo -e "\033[32m 修改mysql密码 \033[0m"
initpasswd=`cat /var/log/mysqld.log |grep root@localhost |awk '{print $NF}'` # 初始密码
echo "MySQL的初始密码是:$initpasswd"
read -p "请输入您要设置MySQL的root用户密码,密码要符合复杂性,否则会失败:" passwd
export MYSQL_PWD=$initpasswd #解决mysql>5.6会提示密码安全问题
mysql -uroot -p${initpasswd} --connect-expired-password -e "alter user 'root'@'localhost' identified by \"$passwd\";use mysql;update user set host = '%' where user ='root';flush privileges;"
if [ "$?" -eq 0 ];then
action "MySQL数据库安装成功,密码为:$passwd" /bin/true
else
action "MySQL数据库安装失败密码初始化失败!" /bin/false
exit 1
fi
echo -e "\033[32m mysql使用及目录 \033[0m"
mysql -uroot -p$passwd -e "show databases;"
if [[ $? -eq 0 ]]; then
echo -e "\033[32m MySQL8.0安装完成,数据目录: /var/lib/mysql 请使用: mysql -uroot -p$passwd 命令进行连接\033[0m"
else
echo -e "\033[5;41;32m MySql8.0安装失败,请排查错误信息。重新安装请卸载后,重新执行脚本安装 \033[1;m"
fi
}
#-------------------------------node 30.卸载mysql5.7函数----------------------------------------------------------------
uninstall_mysql(){
mysql_rpm_list=`rpm -qa |grep mysql`
if [ -n "$mysql_rpm_list" ]; then
echo "mysql检查结果:系统已安装mysql,需先卸载,已安装的MySQL如下:"
rpm -qa | grep mysql | tee
read -p "是否卸载已安装的MySQL?(Y/N):" choose_UnMySQL
if [ "$choose_UnMySQL" == 'Y' ] || [ "$choose_UnMySQL" == 'y' ];then
echo "开始卸载MySQL..."
systemctl stop mysqld
systemctl disable mysqld
rm -rf /var/lib/mysql
rm -rf /usr/share/mysql
rm -rf /var/log/mysqld.log
rpm -qa |grep mysql | xargs rpm -e --nodeps > /dev/null 2>&1
sleep 2
echo "MySQL卸载完成!"
else
exit 0
fi
else
echo "mysql检查结果:系统未安装MySQL."
fi
}
#------------------------------node 31.卸载rabbitmq3.9函数---------------------------------------------------------------
uninstall_rabbitmq(){
rabbit_rpm_list=`rpm -qa |grep rabbitmq`
if [ -n "$rabbit_rpm_list" ]; then
echo "rabbitmq检查结果:系统已安装rabbitmq,需先卸载,已安装的rabbitmq如下:"
rpm -qa | grep rabbitmq | tee
read -p "是否卸载已安装的rabbitmq?(Y/N):" choose_Unrabbitmq
if [ "$choose_Unrabbitmq" == 'Y' ] || [ "$choose_Unrabbitmq" == 'y' ];then
echo "开始卸载rabbitmq..."
service rabbitmq-server stop
systemctl disable rabbitmq-server
rm -rf /var/lib/rabbitmq
rm -rf /etc/rabbitmq
rm -rf /var/log/rabbitmq
rpm -qa |grep rabbitmq | xargs rpm -e --nodeps > /dev/null 2>&1
sleep 2
echo -e "\033[32m rabbitmq卸载完成! \033[0m"
else
exit 0
fi
else
echo -e "\033[32m rabbitmq检查结果:系统未安装rabbitmq. \033[0m"
fi
}
#------------------------------node 32.卸载mariadb10.0.33函数---------------------------------------------------------------
uninstall_mariadb(){
read -p "是否卸载已安装的mariadb?(Y/N):" choose_Unmariadb
if [ "$choose_Unmariadb" == 'Y' ] || [ "$choose_Unmariadb" == 'y' ];then
echo "开始卸载mariadb..."
/etc/init.d/mysqld stop
chkconfig --del mysqld
rm -rf /var/lib/mysql
rm -rf /usr/local/mariadb10.0.33
rm -rf /etc/my.cnf
mv /etc/my.cnf.bak /etc/my.cnf
echo -e "\033[32m mariadb卸载完成! \033[0m"
else
exit 0
fi
}
#-------------------------------分割线---------------------------------------------------------------------------
#----------------------------------------头部说明函数------------------------------------------------------------
clear
. /etc/init.d/functions
cat <
| 使用此脚本说明如下: |
| 系统适配:此脚本只在Centos7系统下测试过,其它系统请自行修改 |
| 安装方式:RPM安装,多用于离网环境(联网环境下安装更是没毛病) |
| 安装说明:带(*)标注的是需要联网环境 |
| 卸载说明:卸载方式只适用于此脚本的安装方式 |
+--------------------------------------------------------------------------+
EOF
show_menu
#-----------------------------------安装程序正文-------------------------------------------------------------------------------------
while [ opt != '' ]
do
if [[ $opt = "" ]]; then
exit;
else
case $opt in
1) clear;
option_picked "Option 1 Picked";
echo -e "\033[32m 开始关闭防火墙和系统参数优化操作,请稍后....... \033[0m"
disable_firewalld
install_space
show_menu;
;;
2) clear;
option_picked "Option 2 Picked";
echo -e "\033[32m 开始安装Nginx_1.22服务,请稍后.......... \033[0m"
install_nginx
install_space
show_menu;
;;
3) clear;
option_picked "Option 3 Picked";
echo -e "\033[32m 开始安装Mysql_5.7服务,请稍后........ \033[0m"
install_mysql
install_space
show_menu;
;;
4) clear;
option_picked "Option 4 Picked";
echo -e "\033[32m 开始安装Jdk_1.8,请稍后...... \033[0m"
install_jdk
install_space
show_menu;
;;
5) clear;
option_picked "Option 5 Picked";
echo -e "\033[32m 开始安装Redis_5.0,请稍后...... \033[0m"
install_redis
install_space
show_menu;
;;
6) clear;
option_picked "Option 6 Picked";
echo -e "\033[32m 开始安装Minio,请稍后...... \033[0m"
install_minio
install_space
show_menu;
;;
7) clear;
option_picked "Option 7 Picked";
echo -e "\033[32m 开始安装Rabbitmq_3.9,请稍后...... \033[0m"
install_rabbitmq
install_space
show_menu;
;;
8) clear;
option_picked "Option 8 Picked";
echo -e "\033[32m 开始安装Opencv_4.5.5,请稍后...... \033[0m"
install_opencv_4.5.5
install_space
show_menu;
;;
9) clear;
option_picked "Option 9 Picked";
echo -e "\033[32m 开始安装mariadb_10.0.33,请稍后...... \033[0m"
sleep 2
install_mariadb
install_space
show_menu;
;;
10) clear;
option_picked "Option 10 Picked";
echo -e "\033[32m 开始安装elasticsearch_7.10.2,请稍后...... \033[0m"
install_elasticsearch
install_space
show_menu;
;;
20) clear;
option_picked "Option 20 Picked";
echo -e "\033[32m 开始安装Opencv_2.4.13,请稍后...... \033[0m"
install_opencv_2.4.13
install_space
show_menu;
;;
21) clear;
option_picked "Option 21 Picked";
echo -e "\033[32m 开始安装Gitlab_7.10.5,因gitlab组件需要mariadb和redis支持,会先安装【5】和【9】,请稍后...... \033[0m"
sleep 2
install_gitlab
install_space
show_menu;
;;
22) clear;
option_picked "Option 22 Picked";
echo -e "\033[32m 开始安装mysql_8.0,请稍后...... \033[0m"
install_mysql8
install_space
show_menu;
;;
30) clear;
option_picked "Option 30 Picked";
echo -e "\033[32m 开始卸载Mysql_5.7,请稍后...... \033[0m"
uninstall_mysql
install_space
show_menu;
;;
31) clear;
option_picked "Option 31 Picked";
echo -e "\033[32m 开始卸载Rabbitmq_3.9,请稍后...... \033[0m"
uninstall_rabbitmq
install_space
show_menu;
;;
32) clear;
option_picked "Option 32 Picked";
echo -e "\033[32m 开始卸载Mariadb_10.0.33,请稍后...... \033[0m"
uninstall_mariadb
install_space
show_menu;
;;
q)exit;
;;
\n)exit;
;;
*)clear;
option_picked "您选择的序号不存在!请选择序号内的数字,不要瞎整!!!";
show_menu;
;;
esac
fi
done
最终显示界面如下: