linux下超级程序!在linux界面实现类图像化界面的操作体验!

发布时间:2024年01月02日

linux下超级程序!在linux界面实现类图像化界面的操作体验!

本期带来一个超级程序!在linux界面实现类图像化界面的操作体验。具体功能代码如下:
在这里插入图片描述

1500行完整代码

在这里插入图片描述

想要完成部署,只需在本地创建一个LinuxGJ.sh的文件,然后将源码复制进去即可,启动的时候使用指令,sh LinuxGJ.sh即可开启使用!
完成源码如下:

 #!/usr/bin/bash                               
 # *******************************************#
 #                                            #
 # * CDDN          : M乔木                    #
 # * qq邮箱        : 2776617348@qq.com        #
 # * 创建时间      : 2023-12-29 11:40:59      #
 # * 解释器        : 这是一个shell脚本        #
 #                                            #
 # *******************************************#
#声明函数
function phpintnginx(){
    clear 
    echo "开始配置nginx支持php页面..."
    sleep 1
    echo "开始配置nginx请求php信息..."
    cd /etc/nginx/
    mv nginx.conf nginx.conf.LinuxGj
    sleep 1
    echo "你的初始化nginx配置文件已更名为:nginx.conf.LinuxGj"
    echo "正在创建新的配置文件..."
    cat >>nginx.conf<<EOF
# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 4096;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    include /etc/nginx/conf.d/*.conf;

    server {
        listen       80;
        listen       [::]:80;
        server_name  _;
        root         /usr/share/nginx/html;

        include /etc/nginx/default.d/*.conf;

        error_page 404 /404.html;
        location = /404.html {
        }

        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
        }
    }
        location / {
             root   html;
              index  index.php index.html index.htm;
          }
        location ~ \.php$ {
             root           html;
             fastcgi_pass   127.0.0.1:9000;
             fastcgi_index  index.php;
             fastcgi_param  SCRIPT_FILENAME  /usr/local/nginx/html$fastcgi_script_name;
             include        fastcgi_params;
         }
}
EOF
    cd /
    sleep 1
    echo "正在检查配置文件语法..."
    nginx -t &>/dev/null
    nginx -s reload &>/dev/null
    sleep 1
    echo "nginx关联php文件成功"
    wbcg
}
function pingip(){
> /opt/a.md
> /opt/b.md
for i in {1..254}
do
{
	ping -W1 -c3 10.12.153.$i &>/dev/null
	if [ $? -eq 0  ]
	then
		echo "10.12.153.${i} 此ip繁忙" >> /opt/b.md 
	else
		echo "10.12.153.${i} 此ip空闲" >> /opt/a.md
	fi
}&
done
read =p "请选择查看空闲IP还是已用iP[1|2]" IPnumxz
case $IPnumxz in
1)
echo "========================================="
echo "已显示前十条空闲ip"
cat /opt/a.md | head
echo "========================================="
  sleep 6
   ;;
2)
echo "========================================="
echo "已显示前十条已用ip"
cat /opt/b.md | head
echo "========================================="
sleep 6
   ;;
*)
   echo "序列号输入错误重新运行"
	pingip
esac
rm -f /opt/a.md
rm -f /opt/b.md
    onekey
}
function akey(){
    clear
    cat<<EOF
******************
*1.启动apache    *
*2.停止apache    *
*3.重启apache    *
*4.查看apache状态*
*5.返回上一级    *
*6.退出程序      *
******************
EOF
read -p "请输入序列号" akeynum
case $akeynum in
1)  
    systemctl start httpd
    echo "已启动apache"
    sleep 2
    akey
    ;;
2)
    systemctl stop httpd
    echo "已停止apache"
    sleep 2
    akey
    ;;
3)
    systemctl restart httpd
    echo "已重启apache"
    sleep 2
    akey
    ;;
4)  
    systemctl status httpd
    echo "已打开apache状态"
    sleep 3
    akey
    ;;
5)  
    lnmpkey
    ;;
6)
    clear 
    cat <<EOF
***************
*"已退出程序!"*
***************
EOF
    exit 0
    ;;
*)
    echo "序列号输入错误"
    sleep 1
    echo "重新输入"
    akey
    esac
}
function pkey(){
    clear
    cat<<EOF
*****************
*1.启动php      *
*2.停止php      *
*3.重启php      *
*4.查看php状态  *
*5.返回上一级   *
*6.退出程序     *
*****************
EOF
read -p "请输入序列号" pkeynum
case $pkeynum in
1)  
    systemctl start php-fpm
    echo "已启动php"
    sleep 2
    pkey
    ;;
2)
    systemctl stop php-fpm
    echo "已停止php"
    sleep 2
    pkey
    ;;
3)
    systemctl restart php-fpm
    echo "已重启php"
    sleep 2
    pkey
    ;;
4)  
    systemctl status php-fpm
    echo "已打开php状态"
    sleep 3
    pkey
    ;;
5)  
    lnmpkey
    ;;
6)
    clear 
    cat <<EOF
***************
*"已退出程序!"*
***************
EOF
    exit 0
    ;;
*)
    echo "序列号输入错误"
    sleep 1
    echo "重新输入"
    pkey
    esac
}
function mkey(){
    clear
    cat<<EOF
*****************
*1.启动MySQL    *
*2.停止MySQL    *
*3.重启MySQL    *
*4.查看MySQL状态*
*5.返回上一级   *
*6.退出程序     *
*****************
EOF
read -p "请输入序列号" mkeynum
case $mkeynum in
1)  
    systemctl start mysqld
    echo "已启动MySQL"
    sleep 2
    mkey
    ;;
2)
    systemctl stop mysqld
    echo "已停止MySQL"
    sleep 2
    mkey
    ;;
3)
    systemctl restart mysqld
    echo "已重启MySQL"
    sleep 2
    mkey
    ;;
4)  
    systemctl status mysqld
    echo "已打开MySQL状态"
    sleep 3
    mkey
    ;;
5)  
    lnmpkey
    ;;
6)
    clear 
    cat <<EOF
***************
*"已退出程序!"*
***************
EOF
    exit 0
    ;;
*)
    echo "序列号输入错误"
    sleep 1
    echo "重新输入"
    mkey
    esac
}
function nkey(){
    clear
    cat<<EOF
*****************
*1.启动nginx    *
*2.停止nginx    *
*3.重启nginx    *
*4.查看nginx状态*
*5.返回上一级   *
*6.退出程序     *
*****************
EOF
read -p "请输入序列号" nkeynum
case $nkeynum in
1)  
    systemctl start nginx
    echo "已启动nginx"
    sleep 2
    nkey
    ;;
2)
    systemctl stop nginx
    echo "已停止nginx"
    sleep 2
    nkey
    ;;
3)
    systemctl restart nginx
    echo "已重启nginx"
    sleep 2
    nkey
    ;;
4)  
    systemctl status nginx
    echo "已打开nginx状态"
    sleep 3
    nkey
    ;;
5)  
    lnmpkey
    ;;
6)
    clear 
    cat <<EOF
***************
*"已退出程序!"*
***************
EOF
    exit 0
    ;;
*)
    echo "序列号输入错误"
    sleep 1
    echo "重新输入"
    nkey
    esac
}
function lnmpkey(){
    clear
    cat<<EOF
*********************
*1.nginx管理        *
*2.MySQL管理        *
*3.PHP管理          *
*4.apache管理       *
*5.返回主菜单       *
*6.退出程序         *
*********************
EOF
read -p "请输入序列号" numlnmp
case $numlnmp in
1)  
    nkey
    ;;
2)  
    mkey
    ;;
3)
    pkey
    ;;
4)
    akey
    ;;
5)
    menus
    ;;
6)
    clear 
    cat <<EOF
***************
*"已退出程序!"*
***************
EOF
    exit 0
    ;;
*)
    echo "序列号输入错误"
    sleep 1
    echo "重新输入"
    lnmpkey
esac
}
function onekey(){
    clear
    cat<<EOF
**********************
*1.LNMP管理界面      *
*2.查看空闲局域网IP  *
*3.切换系统提示到中文*
*4.查看防火墙selinux *
*5.查看yum仓库       *
*6.返回主菜单        * 
*7.退出程序          *      
**********************
EOF
read -p "请输入序列号" numkey
case $numkey in
1)
    lnmpkey
    ;;
2)
    pingip
    ;;
3)
    export  LANG=zh_CN.UTF-8 &>/dev/null
    onekey
    ;;
4)
    getenforce && systemctl status firewalld 
    sleep 5
    onekey
    ;;
5)
    echo "开始清理yum缓存"
    sleep 1
    yum clean all &>/dev/null
    echo "开始生成yum缓存"
    sleep 1
    yum makecache &>/dev/null
    echo "开始抓取yum仓库包数量"
    sleep 1
    yum  repolist 
    sleep 5
    onekey
    ;;
6)
    menus
    ;;
7)
    clear 
    cat <<EOF
***************
*"已退出程序!"*
***************
EOF
    exit 0
    ;;
*)
    echo "序列号输入错误"
    sleep 1
    echo "重新输入"
    onekey
esac
}
function Apachefunct(){
    clear 
    echo "开始安装apache..."
    sleep 1
    #调用函数 关闭防火墙
    fwset
    #安装阿帕奇
    sleep 1
    echo "即将开始安装阿帕奇服务器 本次安转将持续两分钟请耐心等待..."
    yum -y install httpd  &>/dev/null
    #启动阿帕奇
    systemctl start httpd
    echo "apache安装成功! 现在可以使用system工具来使用管理PHP了!"
    sleep 1
cat<<EOF
system工具管理apache
systemctl start httpd  --启动apache
systemctl restart httpd  --重启apache
systemctl stop httpd  --停止apache
systemctl status httpd  --查看apache状态
EOF
    sleep 3
    wbcg
}
function PHPfunct(){
    clear
    echo "开始安装PHP..."
    sleep 1
    echo "本次安装将根据网速的情况持续2分钟到五分钟左右,请耐心等待..."
    yum -y install php php-fpm php-curl php-intl php-mcrypt php-mysql php-mbstring php-xml php-dom php-gd gd &>/dev/null
    echo "PHP安装成功! 现在可以使用system工具来使用管理PHP了!"
    sleep 1
cat<<EOF
system工具管理PHP
systemctl start php-fpm  --启动php
systemctl restart php-fpm  --重启php
systemctl stop php-fpm  --停止php
systemctl status php-fpm  --查看php状态
EOF
    sleep 3
    wbcg
}
function MySqlfunct(){
    clear
    echo "开始安装MySQL..."
    sleep 1
    read -p "请选择是否清理环境[y|n]" hjmysql
    case $hjmysql in
y)  
    echo "开始清理环境"
    yum erase mariadb mariadb-server mariadb-libs mariadb-devel -y &>/dev/null
    userdel -r mysql &>/dev/null
    rm -rf /etc/my* &>/dev/null
    rm -rf /var/lib/mysql  &>/dev/null
    sleep 1
    echo "环境清理完毕..."
    ;;
n)  
    sleep 1
    echo "已跳过清理环境..."
    sleep 1
    ;;
*)  
    echo "序列号输入错误,已退出"
    echo "请重新运行程序"
    exit 9
    esac
    #调用关闭防火墙函数 fwset
    fwset
    #下载MySQLyum源
    echo "开始安装MySQL 整个过程将根据网络持续1~5分钟 请耐心等待..."
    yum install -y https://dev.mysql.com/get/mysql80-community-release-el7-7.noarch.rpm &>/dev/null
    #清理缓存生成缓存
    yum clean all &>/dev/null
    yum makecache &>/dev/null
    #安装MySQL
    yum install -y mysql-community-server --enablerepo mysql57-community --disablerepo mysql80-community &>/dev/null
    #安装结束
    sleep 1
    echo "安装成功!开始感受畅快淋漓的澎湃MySQL的体验"
    read -p "请选择是否关闭密码策略并修改密码[y|n]" MYpasswd
    case $MYpasswd in
y)  
    systemctl start  mysqld
    passwdmysql=`awk '/temporary password/{p=$NF}END{print p}' /var/log/mysqld.log`
    echo '正在设置密码,请稍后'
    echo 'validate-password=OFF' >> /etc/my.cnf
    systemctl restart  mysqld
    read -p '请输入新密码:' passwdmysqldx
    mysqladmin -uroot -p"$passwdmysql" password "$passwdmysqldx" &>/dev/null
    echo '安装完成,密码已设置为:'$passwdmysqldx
    sleep 1
    cat<<EOF
system工具管理MySQL
systemctl start mysqld  --启动MySQL
systemctl restart mysqld  --重启MySQL
systemctl stop mysqld  --停止MySQL
systemctl status mysqld  --查看MySQL状态
EOF
    sleep 3
    wbcg
    ;;
n)
    systemctl start  mysqld
    passwdmysql=`awk '/temporary password/{p=$NF}END{print p}' /var/log/mysqld.log`
    echo "初始密码为:"$passwdmysql
    echo "初始密码为:$passwdmysql" >/MySQL.txt
    sleep 1
    echo "初始密码已发送到根目录下"
    sleep 1
    read -p "是否要修改密码 修改密码要符合密码强度策略[y|n]" passwdxg
    case $passwdxg in
y)  
    read -p "请输入新密码:" adminpasswd
    mysqladmin -uroot -p"$passwdmysql" password "$adminpasswd" &>/dev/null 
    ;;
n)  
    echo ""
    ;;
*)  
    echo "序列号输入错误 无法修改密码"
    sleep 1
    echo "请自行到根下的MySQL.txt文件获取初始密码并修改"
    sleep 1
    echo "修改密码命令已发送到MySQL.txt中 请查收!"
    echo "请使用此命令修改密码:mysqladmin -uroot -p""initial-passwd"" password ""new-passwd""" >> /MySQL.txt
    esac
    cat<<EOF
system工具管理MySQL
systemctl start mysqld  --启动MySQL
systemctl restart mysqld  --重启MySQL
systemctl stop mysqld  --停止MySQL
systemctl status mysqld  --查看MySQL状态
EOF
    sleep 3
    wbcg
    ;;
*)  
    echo "序列号输入错误,已退出"
    echo "已结束运行程序"
    exit 9
    esac
}
function NGfunct(){
    clear
    read -p "安装前是否准备环境[y|n]" NGfunctjc
    case $NGfunctjc in
y)  
    sleep 1
    ;;
n)
    echo "请前往系统设置[关闭防火墙|校准时间|固定IP]"
    sleep 3
    systemft
    ;;
*)
    echo "序列号输入错误,已退出"
    echo "请重新运行程序"
    exit 9
    esac
    echo "开始安装Nginx..."
    yum -y install nginx
    echo "============================================================="
    echo "现在可以使用system工具开始管理Nginx了"
    echo "支持操作 systenctl[start|restart|stop|status]Nginx"
    echo "============================================================="
    sleep 3
    wbcg
}
function JCset(){
    clear	
    #开机欢迎
    SHAN='\E[33;5m'      #黄色闪烁警示
    RES='\E[0m'              # 清除颜色
        echo    "****************************************"
        echo    "*                                      *"
        echo -e "* ${SHAN} 欢迎使用乔木的基础环境配置脚本3.0 ${RES}  *"
        echo    "*  CSDN:    M乔木                      *"
        echo    "*  邮箱:    2776617348@qq.com          *"
        echo    "*                                      *"
        echo    "****************************************" 
		#关闭防火墙
		echo "开始关闭防火墙..."
        sleep 1
		systemctl disable firewalld &>/dev/null
		echo "防火墙已关闭..."
        sleep 1
      		#关闭selinux
		echo "开始关闭selinux..."
        sleep 1
	    sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/sysconfig/selinux	
		echo "selinux已关闭..."
        sleep 1
		#修改主机名 定义变量nameeJC 接收输入
		echo "开始修改主机名..."
        sleep 1
		read -p "请输入你想修改的主机名" nameeJC
		hostnamectl set-hostname $nameeJC
		echo "主机名修改完毕,设置为$nameeJC"
        sleep 1
	#固定IP
        clear
    SHAN='\E[33;5m'      #黄色闪烁警示
    RES='\E[0m'              # 清除颜色
    echo    "****************************************"
    echo    "*                                      *"
    echo -e "* ${SHAN} 欢迎使用固定IP程序 ${RES}                 *"
    echo    "*  CSDN:    M乔木                      *"
    echo    "*  邮箱:    2776617348@qq.com          *"
    echo    "*                                      *"
    echo    "****************************************"
    echo "正在配置网卡,请稍后..."
    sleep 1
    #获取当前网卡配置文件
    echo "获取当前网卡配置文件"
    sleep 1
    wkname=`ls /etc/sysconfig/network-scripts/ | grep ifcfg-ens | cut -d'-' -f2`  
    #获取IP
    echo "获取IP"
    sleep 1
    ipname=`ip -f inet a show dev $wkname | awk "/inet/{print $2}" | awk '{print $2}' | cut -d'/' -f1`
    #删除原有的网卡配置文件
    echo "删除原有的网卡配置文件"
    sleep 1
    rm -rf /etc/sysconfig/network-scripts/ifcfg-$wkname
    #设置判断选择网关
    echo "桥接模式选择1"
    echo "NAT模式选择2"
    echo "自动获取默认网关3"
    read -p "请输入你的网关:[1|2|3] " wgsname
    case $wgsname in
1)
    wgname=10.12.153.254
    ;;
2)
    wgname=192.168.100.2
    ;;
3)  yum -y install net-tools &>/dev/null
    wgname=`route -n | grep '^0.0.0.0' | awk '{print $2}'`
    ;;
*)
    echo "序列号输入错误,已退出"
    echo "请重新运行程序"
    exit 9
    esac
    sleep 1
    #设置判断开启DNS
    read -p "是否开启DNS:[y|n] " dnsname
    case $dnsname in
y)
    dnsa=DNS1=114.114.114.114
    dnsb=DNS2=8.8.8.8
    ;;
n)
    dnsa=#DNS1=114.114.114.114
    dnsb=#DNS2=8.8.8.8
    ;;
*)
    echo "序列号输入错误,已退出"
    echo "请重新运行程序"
    exit 9
    esac
    sleep 1
    #创建新的网卡配置文件
    cd /etc/sysconfig/network-scripts/
    cat >ifcfg-$wkname <<EOF
TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="none"
DEFROUTE="yes"
NAME="$wkname"
DEVICE="$wkname"
ONBOOT="yes"
IPADDR=$ipname
PREFIX=24
GATEWAY=$wgname
$dnsa
$dnsb
EOF
    cd /root
    #重启网络服务
    echo "重启网络服务"
    systemctl restart network
    #结束配置
    echo    "****************************************"
    echo    "*                                      *"
    echo -e "*  ${SHAN} 本次配置结束! ${RES}                     *"
    echo    "*  CSDN:    M乔木                      *"
    echo    "*  邮箱:    2776617348@qq.com          *"
    echo -e "*  ${SHAN} 欢迎下次使用! ${RES}                     *"
    echo    "*                                      *"
    echo    "****************************************"
	#调用函数yumpz	yum仓库函数
	yumpz
	#下载传文件服务
        sleep 1
        echo "开始下载配置命令包并同步网络时间..."
        sleep 1
        echo "下载时间根据网络的不同速度也不同,请耐心等待..."
		yum -y install lrzsz &>/dev/null	
		#校准时间
        yum -y install ntpdate &>/dev/null
        ntpdate time.windows.com &>/dev/null
		#下载cowsay 
		yum -y install cowsay &>/dev/null
		#下载扩展tab补全包
		yum -y install bash-completion &>/dev/null
		#下载vim编辑器
		yum -y install vim &>/dev/null
		#下载wget下载工具
		yum -y install wget &>/dev/null
		#下载网络工具包
		yum -y install net-tools &>/dev/null
		echo "下载结束 同步网络时间成功"
		#开机设置提示 定义变量nameeJC
		echo "开始设置开机提示..."
        sleep 1
		read -p "请输入你想要设置的开机欢迎词" nameeJC
        cd /root/
		echo "开始生成开机提示文件..."
cat >>kj.sh<<EOF		
#!/usr/bin/bash
        #查看cpu负载
        uptime
        #内存使用
        free -m
        #磁盘空间
        df -Th
        #看日历
        cal
        #登录欢迎
        cowsay -f tux "$nameeJC"
        #结束
        echo "欢迎回来" 
EOF
	echo "sh /root/kj.sh" >> /etc/bashrc
		echo "开机提示设置成功..."
        sleep 1
        echo    "****************************************"
        echo    "*                                      *"
        echo -e "*  ${SHAN} 配置结束即将重启... ${RES}               *"
        echo    "*  CSDN:    M乔木                      *"
        echo    "*  邮箱:    2776617348@qq.com          *"
        echo -e "*  ${SHAN} 欢迎下次使用! ${RES}                     *"
        echo    "*                                      *"
        echo    "****************************************"
                #重启程序结束
		reboot
}
function fwset(){
    echo "开始关闭防火墙..."
        sleep 1
		systemctl disable firewalld &>/dev/null
		echo "防火墙已关闭..."
        sleep 1
      		#关闭selinux
		echo "开始关闭selinux..."
        sleep 1
        sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
	    sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/sysconfig/selinux	
		echo "selinux已关闭..."
        sleep 1
        echo "请在稍后重启服务器 否则关闭的服务不会生效"
        sleep 2
}
function hostTS(){
    echo "开始设置开机提示..."
        sleep 1
		read -p "请输入你想要设置的开机欢迎词" TSname
        cd /root/
		echo "开始生成开机提示文件..."
cat >>kj.sh<<EOF		
#!/usr/bin/bash
        #查看cpu负载
        uptime
        #内存使用
        free -m
        #磁盘空间
        df -Th
        #看日历
        cal
        #登录欢迎
        cowsay -f tux "$TSname"
        #结束
        echo "欢迎回来" " 
EOF
	echo "sh /root/kj.sh" >> /etc/bashrc
		echo "开机提示设置成功:$TSname"
}
function hostnames(){
    echo "开始修改主机名..."
        sleep 1
		read -p "请输入你想修改的主机名" nameht
		hostnamectl set-hostname $nameht
		echo "主机名修改完毕,设置为$nameht"
        sleep 1
}
function yumpz(){
    clear
    echo "欢迎使用yum仓库程序"
    sleep 1
    cat <<EOF
***************
*1.局域网仓库 *
*2.阿里仓库   *
***************
EOF
    read -p "请选择连接阿里仓库还是局域网仓库[输入序号]" pzcurl
    case $pzcurl in
1)  echo "开始配置yum源文件..."
    sleep 1
	read -p "请输入你想连接的yum仓库ip地址,回车默认连接1号仓库" yumpzss
    yumipone="10.12.153.1"
    yumpzss=${yumpzss:-$yumipone}
	rm -f /etc/yum.repos.d/* &>/dev/null || rm -rf /etc/yum.repos.d/* && echo "检测到/etc/yum.repos.d/下有目录,已删除"
	cd /etc/yum.repos.d/
	echo "开始创建yum源仓库文件..."
cat >>jc.repo<<EOF
[base]
name=base
baseurl=http://$yumpzss/base
gpgcheck=0
enable=1

[epel]
name=epel
baseurl=http://$yumpzss/epel
gpgcheck=0
enable=1

[extras]
name=extras
baseurl=http://$yumpzss/extras
enable=1
gpgcheck=0

[updates]
name=updates
baseurl=http://$yumpzss/updates
gpgcheck=0
enable=1

[remi-safe]
name=remi-safe
baseurl=http://$yumpzss/remi-safe
gpgcheck=0
enable=1

[mysql57]
name=mysql57
baseurl=http://$yumpzss/mysql57
gpgcheck=0
enable=1 
EOF
    ;;
2)  echo "开始配置yum源文件..."
    sleep 1
    echo "开始清理环境..."
    rm -f /etc/yum.repos.d/* &>/dev/null || rm -rf /etc/yum.repos.d/* && echo "检测到/etc/yum.repos.d/下有目录,已删除"
	#阿里源基础包下载
    curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
    #阿里包加强包下载
    curl -o /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo
    echo "源文件下载完成!"
esac
    sleep 1
    echo "配置yum源文件结束..."
    sleep 1
 	#启动动画
    echo "即将开始配置yum缓存..."
    sleep 1
    #清理缓存
    echo "开始清理本机yum缓存..."
	yum clean all &>/dev/null
    echo "清理完毕..."
    sleep 1
    echo "开始生成本地缓存..."
	yum makecache &>/dev/null
    echo "缓存生成完毕..."
    #列出yum包数
    sleep 1
	echo "即将检索本次安装yun包总数..."
	yum repolist 
    sleep 3
}
function gdIPD(){
    clear
    SHAN='\E[33;5m'      #黄色闪烁警示
    RES='\E[0m'              # 清除颜色
    echo    "****************************************"
    echo    "*                                      *"
    echo -e "* ${SHAN} 欢迎使用固定IP程序 ${RES}                 *"
    echo    "*  CSDN:    M乔木                      *"
    echo    "*  邮箱:    2776617348@qq.com          *"
    echo    "*                                      *"
    echo    "****************************************"
    echo "正在配置网卡,请稍后..."
    sleep 1
    #获取当前网卡配置文件
    echo "获取当前网卡配置文件"
    sleep 1
    #wkname=`ls /etc/sysconfig/network-scripts/ | grep ifcfg-ens | cut -d'-' -f2`
    wkname=`ls /etc/sysconfig/network-scripts/ | awk '/ifcfg/{print}' | cut -d- -f2 | head -1`  
    #获取IP
    echo "获取IP"
    sleep 1
    ipname=`ip -f inet a show dev $wkname | awk "/inet/{print $2}" | awk '{print $2}' | cut -d'/' -f1`
    #删除原有的网卡配置文件
    echo "删除原有的网卡配置文件"
    sleep 1
    rm -rf /etc/sysconfig/network-scripts/ifcfg-$wkname
    #设置判断选择网关
    echo "桥接模式选择1"
    echo "NAT模式选择2"
    echo "自动获取默认网关3"
    read -p "请输入你的网关:[1|2|3] " wgsname
    case $wgsname in
1)
    wgname=10.12.153.254
    ;;
2)
    wgname=192.168.100.2
    ;;
3)  yum -y install net-tools &>/dev/null
    wgname=`route -n | grep '^0.0.0.0' | awk '{print $2}'`
    ;;
*)
    echo "序列号输入错误,已退出"
    echo "请重新运行程序"
    exit 9
    esac
    sleep 1
    #设置判断开启DNS
    read -p "是否开启DNS:[y|n] " dnsname
    case $dnsname in
y)
    dnsa=DNS1=114.114.114.114
    dnsb=DNS2=8.8.8.8
    ;;
n)
    dnsa=#DNS1=114.114.114.114
    dnsb=#DNS2=8.8.8.8
    esac
    sleep 1
    #创建新的网卡配置文件
    cd /etc/sysconfig/network-scripts/
    cat >ifcfg-$wkname <<EOF
TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="none"
DEFROUTE="yes"
NAME="$wkname"
DEVICE="$wkname"
ONBOOT="yes"
IPADDR=$ipname
PREFIX=24
GATEWAY=$wgname
$dnsa
$dnsb
EOF
    cd /root
    #重启网络服务
    echo "重启网络服务"
    systemctl restart network
    #结束配置
    echo    "****************************************"
    echo    "*                                      *"
    echo -e "*  ${SHAN} 本次配置结束! ${RES}                     *"
    echo    "*  CSDN:    M乔木                      *"
    echo    "*  邮箱:    2776617348@qq.com          *"
    echo -e "*  ${SHAN} 欢迎下次使用! ${RES}                     *"
    echo    "*                                      *"
    echo    "****************************************"
}
function systemset(){
clear
cat<<EOF
******************************
*1.固定ip                    *
*2.校准时间                  *
*3.连接yum仓库               *
*4.设置主机名                *
*5.设置开机提示              *
*6.关闭防火墙关闭selinux     *
*7.一键布置环境[功能整合自动]*
*8.返回主菜单                *
*9.退出程序                  *
******************************
EOF
read -p "请输入序列号" setname
case $setname in
1)  gdIPD
    systemset
    ;;
2)  echo "开始校准时间..."
    yum -y install ntpdate &>/dev/null
    ntpdate time.windows.com &>/dev/null 
    sjs=`date`
    echo "时间校准成功"
    echo "当前时间为:"$sjs
    sleep 3
    systemset
    ;;
3)  yumpz
    systemset
    ;;
4)  hostnames
    systemset
    ;;
5)  hostTS
    systemset
    ;;
6)  fwset
    systemset
    ;;
7)  JCset
    ;;
8)  menus
    ;;
9)  clear 
    cat <<EOF
***************
*"已退出程序!"*
***************
EOF
    exit 0
    ;;
*)  
    echo ================================================
    echo 输入错误的序列号请重新运行程序
esac
echo ================================================
cat <<EOF
1.继续查询
2.退出程序
EOF
read -p "请输入序列号" numks
case $numks in 
1)  systemset
    ;;
2)  clear
    echo "已退出"
    ;;
*)  clear
    echo ================================================
    echo 序列号输入错误 已结束运行!
    echo ================================================
    exit 9
esac
echo    "****************************************"
echo    "*                                      *"
echo -e "* ${SHAN} 欢迎下次使用${RES}                        *"
echo    "*  CSDN:    M乔木                      *"
echo    "*  邮箱:    2776617348@qq.com          *"
echo    "*                                      *"
echo    "****************************************"
    exit 0
}
function systemft(){
clear
cat <<EOF
****************
*1.系统信息查询*
*2.系统功能设置*
*3.返回主菜单  *
*4.退出桌面管家*
****************
EOF
read -p "请输入序列号" systemname
case $systemname in
1)  information
    ;;
2)  systemset
    ;;
3)  menus
    ;;
4)  clear 
    cat <<EOF
***************
*"已退出程序!"*
***************
EOF
    exit 0
    ;;
*)  echo ================================================
    echo 输入错误的序列号请重新运行程序
esac
echo ================================================
cat <<EOF
1.继续查询
2.退出程序
EOF
read -p "请输入序列号" numka
case $numka in 
1)  systemft
    ;;
2)
    clear
    echo "已退出"
    ;;
*)  clear
    echo ================================================
    echo 序列号输入错误 已结束运行!
    echo ================================================
    exit 9
esac
echo    "****************************************"
echo    "*                                      *"
echo -e "* ${SHAN} 欢迎下次使用${RES}                        *"
echo    "*  CSDN:    M乔木                      *"
echo    "*  邮箱:    2776617348@qq.com          *"
echo    "*                                      *"
echo    "****************************************"
    exit 0
}
function information(){
clear
SHAN='\E[33;5m'      #黄色闪烁警示
RES='\E[0m'              # 清除颜色
echo    "********************************"
echo    "*                              *"
echo -e "* ${SHAN} 欢迎使用信息查询工具箱${RES}      *"
echo    "*  CSDN:    M乔木              *"
echo    "*  邮箱:    2776617348@qq.com  *"
echo    "*                              *"
echo    "********************************"
cat <<EOF
***************************
*1.剩余空闲内存查询       *
*2.根目录使用的情况       *
*3.当前登录的用户         *
*4.本机ip查询(终端)       *
*5.客户端IP查询(win端设备)*
*6.查询网络情况           *
*7.返回主菜单             *
*8.退出桌面管家           *
***************************
EOF
read -p "请输入序列号" num
case $num in
1)  echo ================================================
    echo 剩余空闲内存:`free -h | awk '/^Mem/{print $4}'`
    ;;
2)  echo ================================================
    echo 总空间:`df -Th | awk '/\/$/{print $3}'`
    echo 已用空间:`df -Th | awk '/\/$/{print $4}'`
    echo 可用空间:`df -Th | awk '/\/$/{print $5}'`
    ;;
3)  echo ================================================
    echo 当前登录的用户:`echo $USER`
    ;;
4)  echo ================================================
    echo 本机ip查询[终端]:`ip a  | grep inet | tail -2 | head -1 | awk '{print $2}' | cut -d'/' -f1`
    ;;
5)  echo ================================================
    echo 客户端IP查询[win端设备]:`w | grep root | tail -1 | awk '{print $3}'`
    ;;
6)  read -p "请输入你的ip地址,回车默认测试本机ip!" ipnum
    ipnmus=`ip a | awk '/inet/{print}' | head -3 | tail -1 | awk '{print $2}' | cut -d/ -f1`
    ipnum=${ipnum:-$ipnmus}
    ping  -W1 -c3 $ipnum &>/dev/null && echo "网络通畅,测试结束" || echo "网络未连接,请检查配置文件"
    ;;
7)  menus
    ;;
8)  clear 
    cat <<EOF
***************
*"已退出程序!"*
***************
EOF
    exit 0
    ;;
*)
    echo ================================================
    echo 输入错误的序列号请重新运行程序
esac
echo ================================================
cat <<EOF
1.继续查询
2.退出程序
EOF
read -p "请输入序列号" numkb
case $numkb in 
1)  information
    ;;
2)
    clear
    echo "已退出"
    ;;
*)  clear
    echo ================================================
    echo 序列号输入错误 已结束运行!
    echo ================================================
    exit 9
esac
echo    "****************************************"
echo    "*                                      *"
echo -e "* ${SHAN} 欢迎下次使用${RES}                        *"
echo    "*  CSDN:    M乔木                      *"
echo    "*  邮箱:    2776617348@qq.com          *"
echo    "*                                      *"
echo    "****************************************"
exit 0
}
function wbcg(){
    echo "LNMP"
clear
cat<<EOF
****************
*1.Nginx       *
*2.MySql       *
*3.PHP         *
*4.Apache      *
*5.关联phpNginx*
*6.返回主菜单  *
*7.退出桌面管家*
****************
EOF
read -p "请输入序号" wbcgid
case $wbcgid in
1)  
    NGfunct
    ;;
2)  
    MySqlfunct
    ;;
3)  
    PHPfunct
    ;;
4)  
    Apachefunct
    ;;
5)  
    phpintnginx
    ;;
6)  
    menus
    ;;
7)  
    clear 
    cat <<EOF
***************
*"已退出程序!"*
***************
EOF
    exit 0
    ;;
*)
    echo ================================================
    echo 输入错误的序列号请重新运行程序
esac
echo ================================================
cat <<EOF
1.继续查询
2.退出程序
EOF
read -p "请输入序列号" numwzgn
case $numwzgn in 
1)  wbcg
    ;;
2)
    clear
    echo "已退出"
    ;;
*)  clear
    echo ================================================
    echo 序列号输入错误 已结束运行!
    echo ================================================
    exit 9
esac
echo    "****************************************"
echo    "*                                      *"
echo -e "* ${SHAN} 欢迎下次使用${RES}                        *"
echo    "*  CSDN:    M乔木                      *"
echo    "*  邮箱:    2776617348@qq.com          *"
echo    "*                                      *"
echo    "****************************************"
    exit 0
}
function bth(){
    echo "飞云"
}
function DBback(){
    echo "开始备份数据库..."
    read -p "请输入你的数据库的用户名" dbname
    read -p "请输入你的数据库密码" dbpasswd
    mkdir /DBbake
    mysqldump -u$dbname -p$dbpasswd -A >/DBbake/"`date +%F-%T`DBbake".sql
    echo "数据库备份完成!存储目录为:/DBbake,请到该目录下查看"
    exit 0
}
function passwdbcm(){
    nb=$RANDOM@
    na=$RANDOM#
    echo $nb$na$nb
}
function appstore(){
clear
cat<<EOF
************************
*      应用商店        * 
************************
*1.vim文本编辑器       *
*2.ntpdate校准时间工具 *
*3.cowsay奶牛说        *
*4.tab补全包           *
*5.wget下载工具        * 
*6.网络工具包          *
*7.lrzsz工具           *
*8.返回主菜单          *       
*9.退出桌面管家        *
************************
EOF
read -p "请输入序号" appnum
case $appnum in
1)  echo "正在下载vim文本编辑器..."
    yum -y install vim &>/dev/null
    echo "安装成功已退出"
    ;;
2)  echo "开始下载ntpdate校准时间工具,并校准时间..."
    yum -y install ntpdate $>/dev/null
    ntpdate time.windows.com &>/dev/null
    echo "安装成功已退出"
    ;;
3)  echo "开始下载cowsay..."
    yum -y install cowsay &>/dev/null
    echo "安装成功已退出"
    ;;
4)  echo "开始下载tab补全包"
    yum -y install bash-completion &>/dev/null
    echo "安装成功已退出"
    ;;
5)  echo "开始下载wget工具..."
    yum -y install wget &>/dev/null
    echo "安装成功已退出"
    ;;
6)  echo "开始下载网络工具包..."
    yum -y install net-tools &>/dev/null
    echo "安装成功已退出"
    ;;
7)  echo "正在上下传文件工具.."
    yum -y install lrzsz &>/dev/null
    echo "安装成功已退出"
    ;;
8)   menus
    ;;
9)  clear 
    cat <<EOF
***************
*"已退出程序!"*
***************
EOF
    exit 0
    ;;
*)  clear
    echo "该序列号软件还未开发,敬请期待"
    echo "已退出程序"
esac
exit 2
}
function menus(){
clear
SHAN='\E[33;5m'      #黄色闪烁警示
RES='\E[0m'              # 清除颜色
echo    "*********************************"
echo    "*                               *"
echo -e "*    ${SHAN} 欢迎使用Linux桌面管家 ${RES}    *"
echo    "*   CSDN:  M乔木                *"
echo    "*   邮箱:  2776617348@qq.com    *"
echo    "*                               *"
echo    "*********************************"
cat <<EOF
********************
*1.系统功能设置    *
*2.LNMP部署        *
*3.飞云堡垒机      *
*4.备份数据库      *
*5.密码生成器      *
*6.应用商店        *
*7.小程序          *
*8.退出程序        *
********************
EOF
read -p "请输入序列号" nova
case $nova in
1)   
    systemft
    ;;
2)   
    wbcg
    ;;
3)   
    echo "功能暂未开发,敬请期待"
    bth
    ;;
4)   
    DBback
    ;;
5)   
    echo "随机密码已生成:" 
    passwdbcm
    ;;
6)   
    appstore
    ;;
7)  
    onekey
    ;;
8)  
    clear 
    cat <<EOF
***************
*"已退出程序!"*
***************
EOF
    exit 0
    ;;
*)  
    clear 
    cat <<EOF
*********************************
*"序列号输入错误,功能暂未开发"  *
*"已退出程序!"                  *
*********************************
EOF
     exit 9
esac
}
#====================================================

#调用显示主菜单 menus
    menus
文章来源:https://blog.csdn.net/qiaomuv/article/details/135323900
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。