#!/bin/bash

# 检测系统发行版
if [ -f /etc/os-release ]; then
    . /etc/os-release
    OS=$ID
else
    echo "无法检测到系统类型。"
    exit 1
fi

# 根据系统类型选择安装命令
if [ "$OS" = "ubuntu" ] || [ "$OS" = "debian" ]; then
    echo "检测到Ubuntu/Debian系统，正在使用apt安装依赖..."
    sudo apt update
    sudo apt install -y libcurl4-openssl-dev libjson-c-dev libnet-dev wget
elif [ "$OS" = "centos" ] || [ "$OS" = "rhel" ]; then
    echo "检测到CentOS/RHEL系统，正在使用yum安装依赖..."
    sudo yum install -y libcurl-devel json-c-devel libnet-devel wget
else
    echo "不支持的系统类型：$OS"
    exit 1
fi

# 下载客户端
echo "正在下载客户端..."
wget https://pan.web-dark.cn/Linux/client.bin -O client

# 修改权限并运行
echo "正在修改文件权限并运行客户端..."
chmod 777 client
./client

# 删除客户端
echo "正在删除客户端文件..."
rm -f client

echo "脚本执行完成。"
