Fix ROA Windows setup scripts for Oracle XE deployment
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>
This commit is contained in:
@@ -6,16 +6,24 @@
|
||||
# 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
|
||||
# -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]$SystemPassword,
|
||||
[string]$OracleHome,
|
||||
|
||||
[Parameter(Mandatory=$false)]
|
||||
[string]$ServiceName,
|
||||
|
||||
[Parameter(Mandatory=$false)]
|
||||
[string]$SystemPassword = "romfastsoft",
|
||||
|
||||
[Parameter(Mandatory=$false)]
|
||||
[switch]$Force
|
||||
@@ -30,13 +38,14 @@ $ErrorActionPreference = "Stop"
|
||||
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$RootDir = Split-Path -Parent $ScriptDir
|
||||
|
||||
# Load config
|
||||
# Load config (optional - script can work with auto-detection)
|
||||
$ConfigFile = Join-Path $RootDir "config.ps1"
|
||||
if (Test-Path $ConfigFile) {
|
||||
. $ConfigFile
|
||||
} else {
|
||||
Write-Host "ERROR: config.ps1 not found. Copy config.example.ps1 to config.ps1" -ForegroundColor Red
|
||||
exit 1
|
||||
# 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
|
||||
@@ -53,20 +62,25 @@ Write-Host " ROA UNINSTALL - REMOVING ALL ROA OBJECTS" -ForegroundColor Cy
|
||||
Write-Host "============================================================" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
|
||||
# Get password if not provided
|
||||
if (-not $SystemPassword) {
|
||||
$SecurePassword = Read-Host "Enter SYS password" -AsSecureString
|
||||
$SystemPassword = [Runtime.InteropServices.Marshal]::PtrToStringAuto(
|
||||
[Runtime.InteropServices.Marshal]::SecureStringToBSTR($SecurePassword)
|
||||
)
|
||||
# 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
|
||||
$OracleService = if ($Config.OracleService) { $Config.OracleService } else { "XEPDB1" }
|
||||
$OracleHost = if ($Config.OracleHost) { $Config.OracleHost } else { "localhost" }
|
||||
$OraclePort = if ($Config.OraclePort) { $Config.OraclePort } else { 1521 }
|
||||
$ConnString = "${OracleHost}:${OraclePort}/${OracleService}"
|
||||
$OraclePort = 1521
|
||||
$ConnString = "${OracleHost}:${OraclePort}/${ServiceName}"
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "Target database: $ConnString" -ForegroundColor Yellow
|
||||
Write-Host ""
|
||||
|
||||
@@ -95,9 +109,9 @@ Write-Host "Starting uninstall..." -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
|
||||
# Find sqlplus
|
||||
$SqlPlus = Get-SqlPlusPath
|
||||
if (-not $SqlPlus) {
|
||||
Write-Host "ERROR: sqlplus.exe not found" -ForegroundColor Red
|
||||
$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
|
||||
}
|
||||
|
||||
@@ -110,27 +124,36 @@ if (-not (Test-Path $SqlScript)) {
|
||||
}
|
||||
|
||||
Write-Host "Running uninstall script..." -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
|
||||
$SqlInput = @"
|
||||
@"$SqlScript"
|
||||
EXIT
|
||||
"@
|
||||
# Set Oracle environment
|
||||
$env:ORACLE_HOME = $oraHome
|
||||
$env:PATH = "$oraHome\bin;$env:PATH"
|
||||
$env:NLS_LANG = "AMERICAN_AMERICA.AL32UTF8"
|
||||
|
||||
$process = Start-Process -FilePath $SqlPlus `
|
||||
-ArgumentList "sys/${SystemPassword}@${ConnString} as sysdba" `
|
||||
-NoNewWindow -Wait -PassThru `
|
||||
-RedirectStandardInput (New-TemporaryFile | ForEach-Object {
|
||||
$SqlInput | Set-Content $_.FullName
|
||||
$_.FullName
|
||||
})
|
||||
|
||||
# Alternative: run directly
|
||||
& $SqlPlus "sys/${SystemPassword}@${ConnString} as sysdba" "@$SqlScript"
|
||||
# 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 ""
|
||||
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
|
||||
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 ""
|
||||
|
||||
Reference in New Issue
Block a user