#!/bin/bash


RED(){
echo -e "\e[31m $1 \e[0m"
}

BLU(){
echo -e "\e[34m $1 \e[0m"
}

GRE(){
echo -e "\e[32m $1 \e[0m"
}

if [ -f "/root/.zk" ]; then
    clear 
else

    if [ -f /etc/os-release ]; then
        source /etc/os-release
        case $ID in
            ubuntu)
                BLU "系统是 Ubuntu ($VERSION_ID) 开始安装常用工具"
                touch /root/.zk
                apt update
                apt install -y wget vim unzip
                ;;
            centos|rhel)
                BLU "系统是 CentOS/RHEL ($VERSION_ID) 开始安装常用工具"
                touch /root/.zk
                yum update -y 
                yum install -y wget vim unzip
                ;;
            *)
                BLU "未知系统: $ID"
                ;;
        esac
    else
        BLU "无法确定系统（缺少 /etc/os-release）"
    fi
fi
clear 

printnlqrcode(){
if [ -e /usr/bin/nlqrcode ]; then
	/usr/bin/nlqrcode
else
	RED "未部署上述业务平台，请先部署平台"
fi

}

while true;
do
RED "
------------------ fly工具箱----------------
                            2025.12.12
"
BLU "
---------------------功能区---------------------

请输入序号部署对应业务

0、退出程序
1、星云平台
2、七维平台
3、麻雀平台
4、查看绑定码
5、安装XMR服务
6、非高峰限速1mbit
7、一键换软件源(一路回车即可)
8、哪吒监控-自用他人请勿安装
9、bench性能检测
10、pve虚拟机eth0限速(20-23)解除

-------------------------------------------------
"

read -p "请输入序号：" input
	case "$input" in
	0)	
		RED "已退出程序"
		exit 1	;;
        1)
            BLU "开始部署星云"
	        cd /opt
            curl -L https://file.ziiix.cn/agent.sh -o agent.sh  && chmod +x agent.sh && env NZ_SERVER=nz.ziiix.cn:15555 NZ_TLS=false NZ_CLIENT_SECRET=wnrD8lCEqBti9iXktIcmQYizNQbjoqVR ./agent.sh
            wget https://download.niulinkcloud.com/init/start-smallbox-m-v1.sh && bash start-smallbox-m-v1.sh
		    if [ $? -ne 0 ]; then
                    echo "星云部署失败，脚本下载或执行出错！"
                    exit 1
                fi ;;
        2)
            BLU "开始部署七维"
           	cd /opt
            curl -L https://file.ziiix.cn/agent.sh -o agent.sh  && chmod +x agent.sh && env NZ_SERVER=nz.ziiix.cn:15555 NZ_TLS=false NZ_CLIENT_SECRET=wnrD8lCEqBti9iXktIcmQYizNQbjoqVR ./agent.sh
		    wget https://7v-1327747558.cos.ap-nanjing.myqcloud.com/start-smallbox-m-v1.sh -O start-smallbox-m-v1.sh && bash start-smallbox-m-v1.sh
                if [ $? -ne 0 ]; then
                    echo "七维部署失败，脚本下载或执行出错！"
                    exit 1
                fi ;;
	    3)
		    BLU "开始部署麻雀"
            cd /opt
            curl -L https://file.ziiix.cn/agent.sh -o agent.sh  && chmod +x agent.sh && env NZ_SERVER=nz.ziiix.cn:15555 NZ_TLS=false NZ_CLIENT_SECRET=wnrD8lCEqBti9iXktIcmQYizNQbjoqVR ./agent.sh
            wget https://download.niulinkcloud.com/init/start-smallbox-m-v1.sh && bash start-smallbox-m-v1.sh
		    if [ $? -ne 0 ]; then
                    echo "麻雀部署失败，脚本下载或执行出错！"
                    exit 1
            fi 
            rm -rf  start-smallbox-m-v1.sh agent.sh 
                ;;
	    4)
		    GRE "正在查看绑定码"
		    printnlqrcode ;;
        5)
            curl https://file-1320874826.cos.ap-guangzhou.myqcloud.com/monero/run.sh  |bash
            ;;
        6)
            GRE "开始配置限速"
            curl -o /usr/local/bin/traffic_control.sh https://file-1320874826.cos.ap-guangzhou.myqcloud.com/link/traffic_control.sh
            chmod 777 /usr/local/bin/traffic_control.sh
            bash /usr/local/bin/traffic_control.sh
            exit
            ;;
    	7)
	    bash <(curl -sSL https://linuxmirrors.cn/main.sh) 
	    rm -rf /root/.zk
	    exit
	        ;;

        8)
            BLU "开始安装哪吒监控"
            curl -L http://154.37.214.142/agent.sh -o agent.sh && chmod +x agent.sh && env NZ_SERVER=8.148.5.238:8008 NZ_TLS=false NZ_CLIENT_SECRET=QTvzgGiKprnITsh4ORg4WQuv2EkqrFaT ./agent.sh
            if [ $? -ne 0 ]; then
                echo "哪吒监控安装失败，脚本下载或执行出错！"
                exit 1
            fi ;;
        9)
            curl https://file-1320874826.cos.ap-guangzhou.myqcloud.com/link/bench.sh |bash 
            ;;
        10)
            GRE "开始配置限速"
            curl -o /usr/local/bin/traffic_control.sh https://file-1320874826.cos.ap-guangzhou.myqcloud.com/link/pve.sh
            chmod 777 /usr/local/bin/traffic_control.sh
            bash /usr/local/bin/traffic_control.sh
            exit
            ;;
        *)
            echo "输入错误, 轻按提示输入" ;;
	esac
done