]> granicus.if.org Git - icinga2/commitdiff
Add uninstall to the chocolatey package
authorRune Darrud <theflyingcorpse@gmail.com>
Sun, 13 Mar 2016 22:13:01 +0000 (23:13 +0100)
committerRune Darrud <theflyingcorpse@gmail.com>
Mon, 14 Mar 2016 17:42:10 +0000 (18:42 +0100)
refs #11369

icinga2.nuspec
tools/chocolateyUninstall.ps1 [new file with mode: 0644]

index 831bb6693316d7b61c049598f6b010d1c56a033b..110e3e5c289910b687a3d4135f9b3728851f461d 100755 (executable)
@@ -22,5 +22,6 @@
   </metadata>\r
   <files>\r
     <file src="tools\chocolateyInstall.ps1" target="tools" />\r
+    <file src="tools\chocolateyUninstall.ps1" target="tools" />\r
   </files>\r
 </package>\r
diff --git a/tools/chocolateyUninstall.ps1 b/tools/chocolateyUninstall.ps1
new file mode 100644 (file)
index 0000000..b9acd34
--- /dev/null
@@ -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
+}