Переписан BGP сервер на FRR
This commit is contained in:
+54
-21
@@ -1,33 +1,66 @@
|
||||
# PowerShell скрипт для остановки BGP сервера
|
||||
# Скрипт остановки BGP Server (FRR)
|
||||
|
||||
Write-Host "=== Stopping BGP Server ===" -ForegroundColor Yellow
|
||||
param(
|
||||
[string]$ContainerName = "bgp-server",
|
||||
[switch]$Force
|
||||
)
|
||||
|
||||
# Проверка что контейнер запущен
|
||||
$containerStatus = docker ps --filter name=bgp-server --format "{{.Status}}"
|
||||
if (!$containerStatus) {
|
||||
Write-Host "BGP server is not running" -ForegroundColor Yellow
|
||||
Write-Host "=== BGP Server (FRR) Stop Script ===" -ForegroundColor Green
|
||||
|
||||
# Проверка существования контейнера
|
||||
$containerExists = docker ps -a --filter "name=$ContainerName" --format "table {{.Names}}" | Select-String $ContainerName
|
||||
|
||||
if (-not $containerExists) {
|
||||
Write-Host "Container $ContainerName not found." -ForegroundColor Yellow
|
||||
exit 0
|
||||
}
|
||||
|
||||
Write-Host "BGP server is running. Stopping..." -ForegroundColor Yellow
|
||||
# Проверка статуса контейнера
|
||||
$containerRunning = docker ps --filter "name=$ContainerName" --format "table {{.Names}}" | Select-String $ContainerName
|
||||
|
||||
# Остановка контейнера
|
||||
docker-compose down
|
||||
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Write-Host "✓ BGP server stopped successfully" -ForegroundColor Green
|
||||
if ($containerRunning) {
|
||||
Write-Host "Container $ContainerName is running. Stopping..." -ForegroundColor Yellow
|
||||
|
||||
if (-not $Force) {
|
||||
$response = Read-Host "Do you want to stop the container? (y/N)"
|
||||
if ($response -ne "y" -and $response -ne "Y") {
|
||||
Write-Host "Operation cancelled." -ForegroundColor Red
|
||||
exit 0
|
||||
}
|
||||
}
|
||||
|
||||
# Graceful shutdown - отзыв префиксов
|
||||
Write-Host "Withdrawing prefixes..." -ForegroundColor Yellow
|
||||
docker exec $ContainerName python3 /app/scripts/load_prefixes.py --withdraw 2>$null
|
||||
|
||||
# Остановка контейнера
|
||||
Write-Host "Stopping container..." -ForegroundColor Yellow
|
||||
docker stop $ContainerName
|
||||
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Write-Host "Container stopped successfully!" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "Failed to stop container." -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
} else {
|
||||
Write-Host "✗ Failed to stop BGP server" -ForegroundColor Red
|
||||
exit 1
|
||||
Write-Host "Container $ContainerName is not running." -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
# Проверка что контейнер остановлен
|
||||
$containerStatus = docker ps --filter name=bgp-server --format "{{.Status}}"
|
||||
if (!$containerStatus) {
|
||||
Write-Host "✓ Container is stopped" -ForegroundColor Green
|
||||
# Удаление контейнера если требуется
|
||||
if ($Force) {
|
||||
Write-Host "Removing container..." -ForegroundColor Yellow
|
||||
docker rm $ContainerName 2>$null
|
||||
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Write-Host "Container removed successfully!" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "Container was already removed or removal failed." -ForegroundColor Yellow
|
||||
}
|
||||
} else {
|
||||
Write-Host "✗ Container is still running" -ForegroundColor Red
|
||||
exit 1
|
||||
Write-Host "Container stopped but not removed." -ForegroundColor Cyan
|
||||
Write-Host "To remove container, run: docker rm $ContainerName" -ForegroundColor Cyan
|
||||
Write-Host "Or use -Force parameter to stop and remove in one command." -ForegroundColor Cyan
|
||||
}
|
||||
|
||||
Write-Host "=== BGP Server Stopped ===" -ForegroundColor Green
|
||||
Write-Host "BGP Server (FRR) stopped successfully!" -ForegroundColor Green
|
||||
Reference in New Issue
Block a user