gitea-install/uninstall.ps1

52 lines
1.5 KiB
PowerShell
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#Requires -Version 5.1
param(
[switch]$Purge
)
$script:ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
Set-Location $script:ScriptDir
. "$script:ScriptDir\lib\common.ps1"
$ErrorActionPreference = "Stop"
try {
Test-Dependencies
if ($Purge) {
Write-Warn "Будут удалены контейнеры и все данные (тома Docker)!"
}
else {
Write-Warn "Контейнеры будут удалены. Тома с данными сохранятся."
}
Confirm-OrExit "Продолжить?"
$task = Get-ScheduledTask -TaskName "Gitea" -ErrorAction SilentlyContinue
if ($task) {
throw "Задача Gitea зарегистрирована в планировщике. Сначала выполните: .\remove-service.ps1"
}
docker compose down
if ($Purge) {
foreach ($vol in Get-VolumeNames) {
$exists = docker volume inspect $vol 2>$null
if ($LASTEXITCODE -eq 0) {
Write-Info "Удаление тома: $vol"
docker volume rm $vol
}
}
Write-Info "Полное удаление завершено."
}
else {
$volumes = (Get-VolumeNames) -join ", "
Write-Info "Контейнеры удалены. Данные сохранены в томах: $volumes"
Write-Info "Для полного удаления данных: .\uninstall.ps1 -Purge"
}
}
catch {
Write-Err $_.Exception.Message
exit 1
}