#!/bin/bash

echo -e "=========================================="
echo -e "\e[31m   服务器防CC脚本(WebHook版)   \e[0m"
echo -e "\e[31m   只适用于Debian/Ubuntu系统   \e[0m"
echo -e "\e[31m    author :云梦工具箱|云梦    \e[0m"
echo -e "=========================================="
echo -e ""
sleep 3s
echo -e "\e[31m正在加载脚本...\e[0m"
sleep 2s
clear
echo -e "1 - \033[36m安装此脚本\033[0m "
echo -e "2 - \033[36m卸载此脚本\033[0m "
echo -e "3 - \033[36m运行^防CC^\033[0m "
echo -e "4 - \033[36m 取消操作 \033[0m "
read -p "请选择:(1/2/3/4)"  SIGN
if [[ $SIGN == '1' ]] ;then
wget https://download.fnmqs.work/cc/cc_attack_detection.sh
echo -e "\e[31m注意注意！！！\e[0m"
echo -e "\e[31m在你的根目录找到名为cc_attack_detection.sh的文件\e[0m"
echo -e "\e[31m修改文件的第4行和第13行\e[0m"
echo -e "\e[31m然后再运行bash cc.sh再选3运行防CC\e[0m"
echo -e "\e[31m此处自动暂停脚本5s方便阅读注意事项\e[0m"
sleep 5s
exit;
elif [[ $SIGN == '2' ]] ;then
cd /etc/init.d
rm -f cc_attack_detection.sh
echo -e "\e[31m卸载完成，谢谢使用\e[0m"
elif [[ $SIGN == '3' ]] ;then
sudo cp cc_attack_detection.sh /etc/init.d/
sudo chmod +x /etc/init.d/cc_attack_detection.sh
sudo update-rc.d cc_attack_detection.sh defaults
sudo /etc/init.d/cc_attack_detection.sh start
sudo /etc/init.d/cc_attack_detection.sh status
echo -e "\e[31m启动脚本：sudo /etc/init.d/cc_attack_detection.sh start\e[0m"
echo -e "\e[31m停止脚本：sudo /etc/init.d/cc_attack_detection.sh stop\e[0m"
echo -e "\e[31m重启脚本：sudo /etc/init.d/cc_attack_detection.sh restart\e[0m"
echo -e "\e[31m检查脚本状态：sudo /etc/init.d/cc_attack_detection.sh status\e[0m"
elif [[ $SIGN == '4' ]] ;then
echo "已取消！！"
exit;
else
echo "输入错误，请重新启动脚本！"
fi