#!/bin/bash

# 下载agent
curl -O https://down.lhip.cc/wg/agent.tar

# 解压到 /root/agent
tar -xvf agent.tar -C /root/

# 获取外网IP
EXT_IP=$(curl -s icanhazip.com)

# 替换配置文件 0.0.0.0 为外网IP
sed -i "s/0.0.0.0/$EXT_IP/g" /root/agent/config/application.properties

# 授权脚本
chmod +x /root/agent/start.sh
chmod +x /root/agent/stop.sh

# 启动agent
/root/agent/start.sh

# 检查进程
echo -e "\n===== 启动完成，检查进程 ====="
ps -ef | grep wgcloud | grep -v grep
