Major Features: - ✅ Multi-tenant architecture (tenant isolation) - ✅ Employee CRUD with lifecycle management (onboarding/offboarding) - ✅ Department tree structure with email domain management - ✅ Company info management (single-record editing) - ✅ System functions CRUD (permission management) - ✅ Email account management (multi-account per employee) - ✅ Keycloak SSO integration (auth.lab.taipei) - ✅ Redis session storage (10.1.0.254:6379) - Solves Cookie 4KB limitation - Cross-system session sharing - Sliding expiration (8 hours) - Automatic token refresh Technical Stack: Backend: - FastAPI + SQLAlchemy - PostgreSQL 16 (10.1.0.20:5433) - Keycloak Admin API integration - Docker Mailserver integration (SSH) - Alembic migrations Frontend: - Next.js 14 (App Router) - NextAuth 4 with Keycloak Provider - Redis session storage (ioredis) - Tailwind CSS Infrastructure: - Redis 7 (10.1.0.254:6379) - Session + Cache - Keycloak 26.1.0 (auth.lab.taipei) - Docker Mailserver (10.1.0.254) Architecture Highlights: - Session管理由 Keycloak + Redis 統一控制 - 支援多系統 (HR/WebMail/Calendar/Drive/Office) 共享 session - Token 自動刷新,異質服務整合 - 未來可無縫遷移到雲端 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
104 lines
3.4 KiB
PowerShell
104 lines
3.4 KiB
PowerShell
# Execute PostgreSQL fix remotely via SSH
|
|
$ErrorActionPreference = "Continue"
|
|
|
|
Write-Host "========================================" -ForegroundColor Cyan
|
|
Write-Host " Fixing PostgreSQL Port Configuration" -ForegroundColor Cyan
|
|
Write-Host "========================================" -ForegroundColor Cyan
|
|
Write-Host ""
|
|
|
|
$REMOTE_HOST = "10.1.0.254"
|
|
$REMOTE_USER = "ubuntu"
|
|
$PASSWORD = "DC1qaz2wsx"
|
|
|
|
# Create the command as a single string
|
|
$commands = @"
|
|
echo '[1/4] Stopping old PostgreSQL container...'
|
|
docker stop postgres 2>/dev/null
|
|
docker rm postgres 2>/dev/null
|
|
|
|
echo ''
|
|
echo '[2/4] Starting new container with external access...'
|
|
docker run -d \
|
|
--name postgres \
|
|
--restart unless-stopped \
|
|
-e POSTGRES_PASSWORD="$PASSWORD" \
|
|
-e TZ=Asia/Taipei \
|
|
-p 0.0.0.0:5432:5432 \
|
|
-v postgres-data:/var/lib/postgresql/data \
|
|
postgres:16
|
|
|
|
echo ''
|
|
echo '[3/4] Waiting for PostgreSQL...'
|
|
sleep 8
|
|
|
|
echo ''
|
|
echo '[4/4] Verifying...'
|
|
docker ps | grep postgres
|
|
docker port postgres
|
|
docker exec postgres psql -U hr_user -d hr_portal -c 'SELECT COUNT(*) FROM information_schema.tables WHERE table_schema='\''public'\'' AND table_type='\''BASE TABLE'\'';' 2>/dev/null || echo 'Database check will be done after connection test'
|
|
|
|
echo ''
|
|
echo '=========================================='
|
|
echo 'PostgreSQL reconfiguration complete!'
|
|
echo '=========================================='
|
|
"@
|
|
|
|
Write-Host "Connecting to Ubuntu Server..." -ForegroundColor Yellow
|
|
Write-Host ""
|
|
|
|
# Try using plink if available
|
|
$plinkPath = Get-Command plink -ErrorAction SilentlyContinue
|
|
|
|
if ($plinkPath) {
|
|
Write-Host "Using plink for connection..." -ForegroundColor Gray
|
|
$commands | plink -ssh -batch -pw $PASSWORD "${REMOTE_USER}@${REMOTE_HOST}"
|
|
} else {
|
|
# Fallback to regular ssh
|
|
Write-Host "Using ssh for connection..." -ForegroundColor Gray
|
|
Write-Host "You may need to enter password: $PASSWORD" -ForegroundColor Yellow
|
|
Write-Host ""
|
|
|
|
# Save commands to temp file
|
|
$tempFile = "$env:TEMP\fix-postgres-commands.sh"
|
|
$commands | Out-File -FilePath $tempFile -Encoding UTF8
|
|
|
|
# Try to execute via ssh with heredoc
|
|
$sshCommand = "bash -s"
|
|
Get-Content $tempFile | ssh "${REMOTE_USER}@${REMOTE_HOST}" $sshCommand
|
|
}
|
|
|
|
$exitCode = $LASTEXITCODE
|
|
|
|
Write-Host ""
|
|
|
|
if ($exitCode -eq 0) {
|
|
Write-Host "========================================" -ForegroundColor Green
|
|
Write-Host " Success!" -ForegroundColor Green
|
|
Write-Host "========================================" -ForegroundColor Green
|
|
Write-Host ""
|
|
Write-Host "PostgreSQL is now accessible from:" -ForegroundColor White
|
|
Write-Host " Host: 10.1.0.254" -ForegroundColor Cyan
|
|
Write-Host " Port: 5432" -ForegroundColor Cyan
|
|
Write-Host ""
|
|
Write-Host "Testing connection from Windows..." -ForegroundColor Yellow
|
|
Write-Host ""
|
|
|
|
# Test connection
|
|
Start-Sleep -Seconds 3
|
|
|
|
Write-Host "Running database connection test..." -ForegroundColor Yellow
|
|
cd "W:\DevOps-Workspace\hr-portal\backend"
|
|
python test_db_connection.py
|
|
|
|
} else {
|
|
Write-Host "========================================" -ForegroundColor Red
|
|
Write-Host " Error occurred" -ForegroundColor Red
|
|
Write-Host "========================================" -ForegroundColor Red
|
|
Write-Host ""
|
|
Write-Host "Exit code: $exitCode" -ForegroundColor Yellow
|
|
Write-Host ""
|
|
Write-Host "Please check the output above for errors." -ForegroundColor Yellow
|
|
}
|
|
|
|
Write-Host ""
|