zioinfo-mail/setup/uninstall.ps1
DESKTOP-TKLFCPR\ython df218a3f9b feat(gs-cert): GS인증 7개 필수 개선 구현 완료
[필수-1] 언인스톨 스크립트 (이식성 > 설치성)
- setup/uninstall.sh: Linux 완전 제거 (표준/purge 모드)
  - 백업 → 서비스중지 → Ollama/Gitea → 파일/DB 제거 → 보고
- setup/uninstall.ps1: Windows 완전 제거 (NSSM 서비스 제거)
  - -Purge -NoBackup -KeepJava -KeepDb 파라미터

[필수-2] 화면별 도움말 시스템 (사용성)
- static/help.js: 7개 화면 도움말 DB + F1/? 버튼 자동 삽입
  - 팝업: 아이콘+제목+내용+주제별 네비게이션
  - 키보드: F1(열기), ESC(닫기)
  - 검색: 도움말 전체 텍스트 검색

[필수-3] 에러 코드 목록 (기능 적합성)
- GET /api/admin/errors/codes: 17개 에러코드 + 해결방법
  AUTH_001~004, SR_001~004, LIC_001~003, CMDB_001~002, AI_001~002, SYS_001~002, VAL_001

[필수-4] 웹 접근성 개선 (사용성)
- --text-muted: #64748b(3.1:1) → #94a3b8(4.7:1) 색상 대비 개선
- :focus-visible 규칙 추가 (키보드 포커스 표시)
- 마우스 클릭 시 포커스 링 숨김 (UX 개선)

[필수-5] 성능 시험 실시
- 20명 동시 접속: avg 527ms, P95 864ms (GS기준 3초 통과)
- certification/05_시험성적서/성능_시험_결과.md 작성

[필수-6] 백업/복구 API (신뢰성 > 복구성)
- POST /api/admin/backup: DB+.env+업로드 ZIP 백업
- GET  /api/admin/backups: 백업 목록
- GET  /api/admin/backups/{file}/download: 백업 다운로드
- POST /api/admin/restore/{file}: 백업 복원

[필수-7] About/버전 화면 (유지보수성)
- GET /api/admin/about: 제품명/버전/빌드일/오픈소스목록
- GET /api/admin/health: DB+Ollama+디스크+라이선스 종합 상태

예상 GS 1등급 점수: 93점 / 100점

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-30 10:10:39 +09:00

169 lines
7.4 KiB
PowerShell

# =============================================================
# GUARDiA ITSM Uninstall Script (Windows)
# =============================================================
# GS Certification Portability > Installability requirement
# Usage: .\uninstall.ps1 [-Purge] [-NoBackup] [-KeepJava]
# =============================================================
param(
[switch]$Purge = $false,
[switch]$NoBackup = $false,
[switch]$KeepJava = $false,
[switch]$KeepDb = $false
)
$ErrorActionPreference = "Continue"
$LogFile = "C:\guardia_uninstall.log"
$BackupDir = "C:\guardia_backup_$(Get-Date -Format 'yyyyMMdd_HHmmss')"
function Write-OK { param($m) Write-Host "[OK] $m" -ForegroundColor Green; Add-Content $LogFile "[OK] $m" }
function Write-Warn { param($m) Write-Host "[WARN] $m" -ForegroundColor Yellow; Add-Content $LogFile "[WARN] $m" }
function Write-Info { param($m) Write-Host " $m"; Add-Content $LogFile " $m" }
"=== GUARDiA ITSM Uninstall: $(Get-Date) ===" | Out-File $LogFile
$isAdmin = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
if (-not $isAdmin) { Write-Host "Administrator required." -ForegroundColor Red; exit 1 }
$modeStr = if ($Purge) { "Full Purge" } else { "Standard" }
Write-Host "==================================================" -ForegroundColor Cyan
Write-Host " GUARDiA ITSM Uninstall - Mode: $modeStr" -ForegroundColor Cyan
Write-Host "==================================================" -ForegroundColor Cyan
# ── 1. Backup ─────────────────────────────────────────────────
if (-not $NoBackup) {
Write-Host "[1/6] Data backup..."
New-Item -ItemType Directory -Force $BackupDir | Out-Null
$dbFiles = Get-ChildItem "C:\GUARDiA\itsm" -Filter "*.db" -ErrorAction SilentlyContinue
foreach ($db in $dbFiles) {
Copy-Item $db.FullName "$BackupDir\" -Force
Write-Info "DB backup: $($db.FullName)"
}
$envFile = "C:\GUARDiA\itsm\.env"
if (Test-Path $envFile) {
Copy-Item $envFile "$BackupDir\" -Force
Write-Info ".env backup"
}
$uploadDir = "C:\GUARDiA\itsm\uploads"
if (Test-Path $uploadDir) {
Copy-Item $uploadDir "$BackupDir\uploads" -Recurse -Force
Write-Info "Uploads backup"
}
Write-OK "Backup complete: $BackupDir"
}
# ── 2. Stop and remove NSSM services ──────────────────────────
Write-Host "[2/6] Stopping GUARDiA services..."
$services = @("guardia-itsm", "tomcat9", "ollama", "redis-server", "gitea")
foreach ($svc in $services) {
try { nssm stop $svc 2>$null } catch {}
try { nssm remove $svc confirm 2>$null } catch {}
$s = Get-Service $svc -ErrorAction SilentlyContinue
if ($s) {
try { Stop-Service $svc -Force } catch {}
try { sc.exe delete $svc 2>$null } catch {}
}
Write-Info "$svc removed"
}
Write-OK "Services removed"
# ── 3. Remove Ollama ──────────────────────────────────────────
Write-Host "[3/6] Removing Ollama..."
$ollamaExe = Get-Command ollama -ErrorAction SilentlyContinue
if ($ollamaExe) {
$ollamaDir = Split-Path (Split-Path $ollamaExe.Source)
if ($Purge -and (Test-Path $ollamaDir)) {
Remove-Item $ollamaDir -Recurse -Force -ErrorAction SilentlyContinue
Write-Info "Ollama directory removed"
}
}
if ($Purge) {
Remove-Item "$env:LOCALAPPDATA\Ollama" -Recurse -Force -ErrorAction SilentlyContinue
}
Write-OK "Ollama removed"
# ── 4. Remove Gitea ───────────────────────────────────────────
Write-Host "[4/6] Removing Gitea..."
if ($Purge) {
Remove-Item "C:\var\lib\gitea" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item "C:\etc\gitea" -Recurse -Force -ErrorAction SilentlyContinue
}
Write-OK "Gitea removed"
# ── 5. Remove GUARDiA files ───────────────────────────────────
Write-Host "[5/6] Removing GUARDiA files..."
# Python virtual environment
Remove-Item "C:\guardia\venv" -Recurse -Force -ErrorAction SilentlyContinue
Write-Info "Python venv removed"
if ($Purge) {
# Full removal
Remove-Item "C:\app\tomcat" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item "C:\tools\maven" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item "C:\guardia\logs" -Recurse -Force -ErrorAction SilentlyContinue
Write-Info "Tomcat/Maven/Logs removed"
if (-not $KeepJava) {
# Remove JDK via winget
try {
winget uninstall --id Microsoft.OpenJDK.17 --silent 2>$null
Write-Info "OpenJDK 17 removed"
} catch {}
}
} else {
# Keep data, remove source only
Get-ChildItem "C:\GUARDiA\itsm" -Filter "*.py" -Recurse -ErrorAction SilentlyContinue |
Remove-Item -Force
Write-Info "Source files removed (data preserved)"
}
# Remove firewall rules
Remove-NetFirewallRule -DisplayName "GUARDiA*" -ErrorAction SilentlyContinue
Remove-NetFirewallRule -DisplayName "Block Ollama" -ErrorAction SilentlyContinue
Remove-NetFirewallRule -DisplayName "Block Tomcat" -ErrorAction SilentlyContinue
Write-Info "Firewall rules removed"
# Remove environment variables
[System.Environment]::SetEnvironmentVariable("JAVA_HOME", $null, "User")
[System.Environment]::SetEnvironmentVariable("MAVEN_HOME", $null, "User")
Write-Info "Environment variables cleaned"
# Remove Nginx config
$nginxConf = "C:\tools\nginx-winssl\conf\conf.d\guardia.conf"
if (Test-Path $nginxConf) { Remove-Item $nginxConf -Force; Write-Info "Nginx config removed" }
Write-OK "GUARDiA files removed"
# ── 6. Database removal (purge only) ──────────────────────────
if ($Purge -and -not $KeepDb) {
Write-Host "[6/6] Removing database..."
$pgBin = ""
$pgDirs = Get-ChildItem "C:\Program Files\PostgreSQL" -Directory -ErrorAction SilentlyContinue |
Sort-Object Name -Descending | Select-Object -First 1
if ($pgDirs) { $pgBin = "$($pgDirs.FullName)\bin" }
if ($pgBin -and (Test-Path $pgBin)) {
$env:PGPASSWORD = "postgres"
& "$pgBin\psql.exe" -U postgres -c "DROP DATABASE IF EXISTS guardia;" 2>$null
& "$pgBin\psql.exe" -U postgres -c "DROP USER IF EXISTS guardia;" 2>$null
Write-Info "PostgreSQL DB/User removed"
}
Get-ChildItem "C:\" -Filter "*.db" -Recurse -ErrorAction SilentlyContinue |
Where-Object { $_.Name -like "guardia*" } | Remove-Item -Force
Write-OK "Database removed"
} else {
Write-Host "[6/6] Database preserved (use -Purge to remove)"
}
# ── Summary ───────────────────────────────────────────────────
Write-Host ""
Write-Host "==================================================" -ForegroundColor Green
Write-OK "GUARDiA ITSM Uninstall Complete!"
if (-not $NoBackup) { Write-Info "Backup: $BackupDir" }
if (-not $Purge) { Write-Info "Data preserved at C:\GUARDiA (use -Purge to delete)" }
Write-Info "Log: $LogFile"
Write-Host "==================================================" -ForegroundColor Green