#!/bin/bash
# 在【新服务器】上运行：装 glances + 防火墙只放行 Server1
# 用法：curl -s https://scripts.cong.in/glances.sh | bash
set -e
SERVER1_IP=107.173.199.235
echo '>>> 安装 glances 容器...'
docker rm -f glances 2>/dev/null || true
docker run -d --restart=always --name glances --network host --pid host   -e GLANCES_OPT='-w' nicolargo/glances:latest-full
echo '>>> 配置防火墙（仅允许 Server1 和本机）...'
iptables -D INPUT -p tcp --dport 61208 -j DROP 2>/dev/null || true
iptables -I INPUT -p tcp --dport 61208 -s $SERVER1_IP -j ACCEPT
iptables -I INPUT -p tcp --dport 61208 -s 127.0.0.1 -j ACCEPT
iptables -A INPUT -p tcp --dport 61208 -j DROP
echo '>>> 完成！本机公网IP：'
curl -s ifconfig.me; echo
echo '>>> 下一步：在 Server1 上运行 add-server.sh 把本机IP和名字加进面板'
