Add uninstall to the chocolatey package

refs #11369
This commit is contained in:
Rune Darrud 2016-03-13 23:13:01 +01:00 committed by Michael Friedrich
parent 4c7b5f710f
commit 901618d15b
2 changed files with 26 additions and 0 deletions

View File

@ -22,5 +22,6 @@
</metadata>
<files>
<file src="tools\chocolateyInstall.ps1" target="tools" />
<file src="tools\chocolateyUninstall.ps1" target="tools" />
</files>
</package>

View File

@ -0,0 +1,25 @@
$instDir = "unset"
$uninstaller = "Uninstall.exe"
$icingaRegistry64bitOS = "hklm:\SOFTWARE\Wow6432Node\Icinga Development Team\ICINGA2"
$icingaRegistry32bitOS = "hklm:\SOFTWARE\Icinga Development Team\ICINGA2"
$found = $false
$validExitCodes = @(0)
if(test-path $icingaRegistry32bitOS) {
$instDir = (get-itemproperty -literalpath $icingaRegistry32bitOS).'(default)'
$found = $true
}
elseif(test-path $icingaRegistry64bitOS) {
$instDir = (get-itemproperty -literalpath $icingaRegistry64bitOS).'(default)'
$found = $true
}
else {
Write-Host "Did not find a path in the registry to the Icinga2 folder, did you use the installer?"
}
if ($found) {
$packageArgs = "/S ?_="
$statements = "& `"$instDir\$uninstaller`" $packageArgs`"$instDir`""
Start-ChocolateyProcessAsAdmin "$statements" -minimized -validExitCodes $validExitCodes
}