shell模板-小辉

#!/bin/bash
# author:xiao hui

# color
red='\033[0;31m'
green='\033[0;32m'
yellow='\033[0;33m'
plain='\033[0m'

function firewall(){
echo -e "
${green}===================Firewalld==================${plain}
${green}0、返回主菜单${plain}
${green}1、查看防火墙运行状态状态${plain}
${green}2、查看已放行的所有端口${plain}
${green}3、查看所有已放行的服务${plain}
${green}4、开启Firewalld防火墙${plain}
${green}5、关闭Firewalld防火墙${plain}
${green}6、开放端口${plain}
${green}7、开放服务${plain}
${green}8、关闭端口${plain}
${green}9、关闭服务${plain}
"
	read -p "请输入你需要的数字:" num
	case ${num} in
	0) show_menu
	;;
	1) firewall-cmd --state
		firewall
	;;
	2) firewall-cmd --list-ports
		firewall
	;;
	3) firewall-cmd --list-service
		firewall
	;;
	4) systemctl --now enable firewalld
		firewall
	;;
	5) systemctl --now disable firewalld
		firewall
	;;
	6) read -p "请输入你要开放的端口:" on_port
		firewall-cmd --zone=public --add-port=${on_port}/tcp --permanent
		firewall-cmd --zone=public --add-port=${on_port}/udp --permanent
		firewall-cmd --reload
		firewall
	;;
	7) read -p "请输入你要开放的服务:" on_service
		firewall-cmd --zone=public --add-service=${on_service}/tcp --permanent
		firewall-cmd --zone=public --add-service=${on_service}/udp --permanent
		firewall-cmd --reload
		firewall
	;;
	8) read -p "请输入你要关闭的端口:" off_port
		firewall-cmd --zone=public --remove-port=${off_port}/tcp --permanent
		firewall-cmd --zone=public --remove-port=${off_port}/udp --permanent
		firewall-cmd --reload
		firewall
	;;
	9) read -p "请输入你要关闭的端口:" off_service
		firewall-cmd --zone=public --remove-port=${off_port}/tcp --permanent
		firewall-cmd --zone=public --remove-port=${off_port}/udp --permanent
		firewall-cmd --reload
		firewall
	;;
	*) echo -e "${red}请输入正确的数字!!!${plain}"
		firewall
	;;
	esac
}

before_show_menu(){
    echo && echo -n -e "${yellow}按回车返回主菜单: ${plain}" && read temp
		    show_menu
}

exit_script(){
	exit 1
}

function show_menu(){
cat << "EOF"
——————————————————————————————————————————————————————————————————————
//                          南无啊弥陀佛                            //
//                            _ooOoo_                               //
//                           o8888888o                              //    
//                           88" . "88                              //    
//                           (| ^_^ |)                              //    
//                           O\  =  /O                              //
//                        ____/`---'\____                           //                        
//                      .'  \\|     |//  `.                         //
//                     /  \\|||  :  |||//  \                        //    
//                    /  _||||| -:- |||||-  \                       //
//                    |   | \\\  -  /// |   |                       //
//                    | \_|  ''\---/''  |   |                       //        
//                    \  .-\__  `-`  ___/-. /                       //        
//                  ___`. .'  /--.--\  `. . ___                     //    
//                ."" '<  `.___\_<|>_/___.'  >'"".                  //
//              | | :  `- \`.;`\ _ /`;.`/ - ` : | |                 //    
//              \  \ `-.   \_ __\ /__ _/   .-` /  /                 //
//        ========`-.____`-.___\_____/___.-`____.-'========         //    
//                             `=---='                              //
//        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^        //
//         佛祖开光                               永无shell         //
——————————————————————————————————————————————————————————————————————
EOF
#—————————————————————————————————————————————————————————————————————
echo -e "
  ${green}===================集成脚本===================${plain}
  ${green}(1)firewalld防火墙         (2)系统信息${plain}
  ${green}(3)iptables防火墙          (4)${plain}
  "
read -p '请输入命令编号:' num
case $num in
0) exit_script
;;
1) firewall
;;
*) echo -e "${red}请输入正确的数字!!!${plain}"
;;
esac
}

show_menu

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值