57 lines
2.2 KiB
PowerShell
57 lines
2.2 KiB
PowerShell
# Test server network connectivity
|
|
param(
|
|
[string]$Server = "45.249.208.118",
|
|
[string]$User = "root",
|
|
[string]$Password = "lxvhNYFZ4160"
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
Write-Host "========================================" -ForegroundColor Cyan
|
|
Write-Host "Test Server Network Connectivity" -ForegroundColor Green
|
|
Write-Host "========================================" -ForegroundColor Cyan
|
|
Write-Host ""
|
|
|
|
$plinkPath = "C:\Program Files\PuTTY\plink.exe"
|
|
if (-not (Test-Path $plinkPath)) {
|
|
Write-Host "Error: plink.exe not found" -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
|
|
# Test ping to Docker Hub
|
|
Write-Host "[1/4] Testing connectivity to Docker Hub..." -ForegroundColor Yellow
|
|
$testCmd = "ping -c 2 registry-1.docker.io 2>&1 | head -5"
|
|
$plinkCmd = "`"$plinkPath`" -ssh -pw `"$Password`" -batch ${User}@${Server} `"$testCmd`""
|
|
$result = cmd /c $plinkCmd 2>&1
|
|
Write-Host $result
|
|
Write-Host ""
|
|
|
|
# Test HTTPS connection
|
|
Write-Host "[2/4] Testing HTTPS connection to Docker Hub..." -ForegroundColor Yellow
|
|
$testCmd = "curl -I --connect-timeout 5 https://registry-1.docker.io/v2/ 2>&1 | head -5"
|
|
$plinkCmd = "`"$plinkPath`" -ssh -pw `"$Password`" -batch ${User}@${Server} `"$testCmd`""
|
|
$result = cmd /c $plinkCmd 2>&1
|
|
Write-Host $result
|
|
Write-Host ""
|
|
|
|
# Check if there's a proxy configured
|
|
Write-Host "[3/4] Checking for proxy configuration..." -ForegroundColor Yellow
|
|
$testCmd = "echo `$HTTP_PROXY; echo `$HTTPS_PROXY; echo `$http_proxy; echo `$https_proxy; cat /etc/systemd/system/docker.service.d/http-proxy.conf 2>/dev/null || echo 'No proxy config'"
|
|
$plinkCmd = "`"$plinkPath`" -ssh -pw `"$Password`" -batch ${User}@${Server} `"$testCmd`""
|
|
$result = cmd /c $plinkCmd 2>&1
|
|
Write-Host $result
|
|
Write-Host ""
|
|
|
|
# Check Docker daemon status
|
|
Write-Host "[4/4] Checking Docker daemon status..." -ForegroundColor Yellow
|
|
$testCmd = "systemctl status docker --no-pager -l | head -10"
|
|
$plinkCmd = "`"$plinkPath`" -ssh -pw `"$Password`" -batch ${User}@${Server} `"$testCmd`""
|
|
$result = cmd /c $plinkCmd 2>&1
|
|
Write-Host $result
|
|
|
|
Write-Host ""
|
|
Write-Host "========================================" -ForegroundColor Cyan
|
|
Write-Host "Network test complete" -ForegroundColor Green
|
|
Write-Host "========================================" -ForegroundColor Cyan
|
|
Write-Host ""
|