gongxiangp2/scripts/check-frp-server.sh

61 lines
1.9 KiB
Bash

#!/bin/bash
# 检查FRP服务器配置脚本
# 使用方法: ./check-frp-server.sh
FRP_SERVER="180.97.221.140"
FRP_USER="root"
FRP_PASSWORD="NEjoy4h8B9Fa"
FRP_PORT="22"
echo "========================================="
echo "FRP服务器配置检查"
echo "========================================="
echo ""
# 使用expect处理密码输入
expect << EOF
set timeout 30
spawn ssh -o StrictHostKeyChecking=no -p $FRP_PORT $FRP_USER@$FRP_SERVER
expect {
"password:" {
send "$FRP_PASSWORD\r"
exp_continue
}
"# " {
send "echo '=== FRP服务器信息 ==='\r"
send "hostname\r"
send "uname -a\r"
send "echo ''\r"
send "echo '=== 备份Nginx配置 ==='\r"
send "mkdir -p /root/nginx-backup\r"
send "cp -r /etc/nginx /root/nginx-backup/nginx-\$(date +%Y%m%d_%H%M%S) 2>/dev/null\r"
send "ls -la /root/nginx-backup/ | tail -3\r"
send "echo ''\r"
send "echo '=== 查找Nginx配置文件 ==='\r"
send "find /etc/nginx -name '*.conf' -type f 2>/dev/null\r"
send "echo ''\r"
send "echo '=== 检查端口监听 ==='\r"
send "netstat -tlnp 2>/dev/null | grep -E ':80|:443|:2320'\r"
send "echo ''\r"
send "echo '=== 查找3d.yydd.ai配置 ==='\r"
send "grep -r '3d.yydd.ai' /etc/nginx/ 2>/dev/null || echo '未找到3d.yydd.ai配置'\r"
send "echo ''\r"
send "echo '=== 查看Nginx主配置 ==='\r"
send "cat /etc/nginx/nginx.conf 2>/dev/null\r"
send "echo ''\r"
send "echo '=== 检查sites-enabled目录 ==='\r"
send "ls -la /etc/nginx/sites-enabled/ 2>/dev/null || echo 'sites-enabled目录不存在'\r"
send "echo ''\r"
send "echo '=== 检查FRPS服务 ==='\r"
send "systemctl status frps 2>&1 | head -15 || ps aux | grep frps | grep -v grep\r"
send "exit\r"
}
timeout {
puts "连接超时"
exit 1
}
}
expect eof
EOF