Key fixes: - Add Run.cmd/RunAll.cmd wrappers with ExecutionPolicy Bypass - Add Get-ListenerHost() to auto-detect listener IP address - Fix impdp connection using EZConnect format (host:port/service) - Add parallel=1 for Oracle XE compatibility - Fix Write-Log to accept empty strings with [AllowEmptyString()] - Fix Get-SchemaObjectCount regex for Windows line endings (\r\n) - Fix path comparison for DMP file copy operation - Add GRANT EXECUTE ON SYS.AUTH_PACK TO PUBLIC for PACK_DREPTURI - Fix VAUTH_SERII view to use SYN_NOM_PROGRAME (has DENUMIRE column) - Add sections 10-11 to grants-public.sql for SYS object grants Tested on VM 302 (10.0.20.130) with Oracle XE 21c. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
160 lines
5.7 KiB
PowerShell
160 lines
5.7 KiB
PowerShell
# ============================================================================
|
|
# ROA UNINSTALL SCRIPT
|
|
# ============================================================================
|
|
# Removes all ROA application objects from Oracle database
|
|
#
|
|
# Usage:
|
|
# .\99-uninstall-roa.ps1 -SystemPassword "yourpassword"
|
|
# .\99-uninstall-roa.ps1 -SystemPassword "yourpassword" -Force
|
|
# .\99-uninstall-roa.ps1 -ServiceName "XEPDB1" -SystemPassword "yourpassword" -Force
|
|
#
|
|
# Parameters:
|
|
# -SystemPassword : SYS password for database connection (default: romfastsoft)
|
|
# -ServiceName : Oracle service name (auto-detected if not specified)
|
|
# -Force : Skip confirmation prompt
|
|
#
|
|
# ============================================================================
|
|
|
|
param(
|
|
[Parameter(Mandatory=$false)]
|
|
[string]$OracleHome,
|
|
|
|
[Parameter(Mandatory=$false)]
|
|
[string]$ServiceName,
|
|
|
|
[Parameter(Mandatory=$false)]
|
|
[string]$SystemPassword = "romfastsoft",
|
|
|
|
[Parameter(Mandatory=$false)]
|
|
[switch]$Force
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
# ============================================================================
|
|
# LOAD CONFIGURATION AND LIBRARIES
|
|
# ============================================================================
|
|
|
|
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
$RootDir = Split-Path -Parent $ScriptDir
|
|
|
|
# Load config (optional - script can work with auto-detection)
|
|
$ConfigFile = Join-Path $RootDir "config.ps1"
|
|
if (Test-Path $ConfigFile) {
|
|
. $ConfigFile
|
|
# Use config values if parameters not provided
|
|
if (-not $OracleHome -and $ORACLE_HOME) { $OracleHome = $ORACLE_HOME }
|
|
if (-not $ServiceName -and $SERVICE_NAME) { $ServiceName = $SERVICE_NAME }
|
|
if ($SystemPassword -eq "romfastsoft" -and $SYSTEM_PASSWORD) { $SystemPassword = $SYSTEM_PASSWORD }
|
|
}
|
|
|
|
# Load libraries
|
|
. (Join-Path $ScriptDir "lib\logging-functions.ps1")
|
|
. (Join-Path $ScriptDir "lib\oracle-functions.ps1")
|
|
|
|
# ============================================================================
|
|
# MAIN
|
|
# ============================================================================
|
|
|
|
Write-Host ""
|
|
Write-Host "============================================================" -ForegroundColor Cyan
|
|
Write-Host " ROA UNINSTALL - REMOVING ALL ROA OBJECTS" -ForegroundColor Cyan
|
|
Write-Host "============================================================" -ForegroundColor Cyan
|
|
Write-Host ""
|
|
|
|
# Get Oracle Home
|
|
$oraHome = Get-OracleHome -OracleHome $OracleHome
|
|
Write-Host "[INFO] Oracle Home: $oraHome" -ForegroundColor Green
|
|
|
|
# Get listener host
|
|
$OracleHost = Get-ListenerHost -OracleHome $oraHome
|
|
Write-Host "[INFO] Database Host: $OracleHost" -ForegroundColor Green
|
|
|
|
# Auto-detect service name if not specified
|
|
if (-not $ServiceName) {
|
|
$ServiceName = "XEPDB1" # Default for Oracle XE
|
|
}
|
|
Write-Host "[INFO] Service Name: $ServiceName" -ForegroundColor Green
|
|
|
|
# Build connection string
|
|
$OraclePort = 1521
|
|
$ConnString = "${OracleHost}:${OraclePort}/${ServiceName}"
|
|
|
|
Write-Host ""
|
|
Write-Host "Target database: $ConnString" -ForegroundColor Yellow
|
|
Write-Host ""
|
|
|
|
# Confirmation
|
|
if (-not $Force) {
|
|
Write-Host "WARNING: This will PERMANENTLY DELETE all ROA data!" -ForegroundColor Red
|
|
Write-Host ""
|
|
Write-Host "Objects to be removed:" -ForegroundColor Yellow
|
|
Write-Host " - All company user schemas (using ROA tablespace)"
|
|
Write-Host " - CONTAFIN_ORACLE user and all objects"
|
|
Write-Host " - Public synonyms pointing to CONTAFIN_ORACLE"
|
|
Write-Host " - SYS custom objects (AUTH_PACK, AUTH_SERII, etc.)"
|
|
Write-Host " - Application context SESIUNE"
|
|
Write-Host " - Tablespace ROA (including datafile)"
|
|
Write-Host ""
|
|
|
|
$confirm = Read-Host "Type 'YES' to confirm uninstall"
|
|
if ($confirm -ne "YES") {
|
|
Write-Host "Uninstall cancelled." -ForegroundColor Yellow
|
|
exit 0
|
|
}
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host "Starting uninstall..." -ForegroundColor Cyan
|
|
Write-Host ""
|
|
|
|
# Find sqlplus
|
|
$SqlPlus = Join-Path $oraHome "bin\sqlplus.exe"
|
|
if (-not (Test-Path $SqlPlus)) {
|
|
Write-Host "ERROR: sqlplus.exe not found at $SqlPlus" -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
|
|
# Run uninstall script
|
|
$SqlScript = Join-Path $RootDir "sql\uninstall-roa.sql"
|
|
|
|
if (-not (Test-Path $SqlScript)) {
|
|
Write-Host "ERROR: uninstall-roa.sql not found at $SqlScript" -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
|
|
Write-Host "Running uninstall script..." -ForegroundColor Cyan
|
|
Write-Host ""
|
|
|
|
# Set Oracle environment
|
|
$env:ORACLE_HOME = $oraHome
|
|
$env:PATH = "$oraHome\bin;$env:PATH"
|
|
$env:NLS_LANG = "AMERICAN_AMERICA.AL32UTF8"
|
|
|
|
# Execute uninstall SQL script
|
|
try {
|
|
& $SqlPlus "sys/${SystemPassword}@${ConnString} as sysdba" "@$SqlScript"
|
|
$exitCode = $LASTEXITCODE
|
|
}
|
|
catch {
|
|
Write-Host "ERROR: Failed to execute uninstall script: $_" -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
|
|
Write-Host ""
|
|
if ($exitCode -eq 0) {
|
|
Write-Host "============================================================" -ForegroundColor Green
|
|
Write-Host " ROA UNINSTALL COMPLETE" -ForegroundColor Green
|
|
Write-Host "============================================================" -ForegroundColor Green
|
|
Write-Host ""
|
|
Write-Host "Database is now clean. You can re-run the setup scripts." -ForegroundColor Cyan
|
|
}
|
|
else {
|
|
Write-Host "============================================================" -ForegroundColor Yellow
|
|
Write-Host " ROA UNINSTALL COMPLETED WITH WARNINGS" -ForegroundColor Yellow
|
|
Write-Host "============================================================" -ForegroundColor Yellow
|
|
Write-Host ""
|
|
Write-Host "Some objects may not have been removed. Review output above." -ForegroundColor Yellow
|
|
}
|
|
Write-Host ""
|