Skip to content

Commit 1820435

Browse files
authored
fix: add uninstall script into ac folder and delete .key to prevent reinstall errors (#2616)
1 parent d1142b4 commit 1820435

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

build/package/windows/install.ps1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,12 @@ Set-RestrictedAcl -Path $acDataDir
127127
Write-Host "Copying New Relic Agent Control program files..."
128128
Copy-Item -Path ".\newrelic-agent-control.exe" -Destination "$acProgramFilesDir"
129129

130+
# Copy uninstall script if it exists
131+
if (Test-Path ".\uninstall.ps1") {
132+
Copy-Item -Path ".\uninstall.ps1" -Destination "$acProgramFilesDir\uninstall.ps1"
133+
Write-Host "Uninstall script copied to $acProgramFilesDir"
134+
}
135+
130136
# Generate configuration based on inputs
131137
$localConfigPath = Join-Path $acLocalConfigDir 'local_config.yaml'
132138

build/package/windows/uninstall.ps1

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ if (-not $currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Adm
1111
$serviceName = "newrelic-agent-control"
1212
$acDir = [IO.Path]::Combine($env:ProgramFiles, 'New Relic\newrelic-agent-control')
1313
$acExecPath = [IO.Path]::Combine($acDir, 'newrelic-agent-control.exe')
14+
$acKeysDir = [IO.Path]::Combine($acDir, 'keys')
1415

1516
$markerPath = [IO.Path]::Combine($acDir, '.nr-ac-install')
1617

@@ -33,6 +34,12 @@ if (Test-Path $acExecPath) {
3334
Remove-Item -Path $acExecPath -Force
3435
}
3536

37+
# Remove the keys directory if exists
38+
if (Test-Path $acKeysDir) {
39+
Write-Host "Removing keys directory..."
40+
Remove-Item -Path $acKeysDir -Recurse -Force
41+
}
42+
3643
if (Test-Path $markerPath) {
3744
Write-Host "Removing installation marker file..."
3845
Remove-Item -Path $markerPath -Force

0 commit comments

Comments
 (0)