Merge pull request #10 from Iristyle/sabnzbdfixes

Bumped to 0.7.4.1
This commit is contained in:
Ethan J. Brown
2012-10-22 04:45:02 -07:00
4 changed files with 162 additions and 34 deletions

View File

@@ -3,7 +3,7 @@
<metadata> <metadata>
<id>SABnzbd</id> <id>SABnzbd</id>
<title>SABnzbd+</title> <title>SABnzbd+</title>
<version>0.7.4</version> <version>0.7.4.1</version>
<authors>The SABnzbd+ Team</authors> <authors>The SABnzbd+ Team</authors>
<owners>Ethan Brown</owners> <owners>Ethan Brown</owners>
<summary>SABnzbd+ open source binary newsreader</summary> <summary>SABnzbd+ open source binary newsreader</summary>
@@ -20,7 +20,11 @@ Note that if this is a first time install it will be necessary to configure SABn
<licenseUrl>https://github.com/sabnzbd/sabnzbd/blob/master/LICENSE.txt</licenseUrl> <licenseUrl>https://github.com/sabnzbd/sabnzbd/blob/master/LICENSE.txt</licenseUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance> <requireLicenseAcceptance>false</requireLicenseAcceptance>
<iconUrl>https://github.com/Iristyle/ChocolateyPackages/raw/master/SABnzbd/SABnzbd.png</iconUrl> <iconUrl>https://github.com/Iristyle/ChocolateyPackages/raw/master/SABnzbd/SABnzbd.png</iconUrl>
<releaseNotes>Highlights in 0.7.4 <releaseNotes>
0.7.4.1 - Chocolatey Installer fixes
Can now uninstall
Highlights in 0.7.4
OSX Mountain Lion: Notification Center support OSX Mountain Lion: Notification Center support
OSX Mountain Lion: improved "keep awake" support OSX Mountain Lion: improved "keep awake" support

View File

@@ -0,0 +1,24 @@
function WaitForSuccess([ScriptBlock] $script, [int]$seconds = 10,
[string]$description = 'operation to complete')
{
$skip = $false
Write-Host "Waiting up to $($seconds)s for $description..."
$result = 0..($seconds * 2) |
% {
if ($skip) { return $true }
$status = &$script
if ($status -eq $true)
{
$skip = $true
return $true
}
elseif ($service)
{
Start-Sleep -Milliseconds 500
}
return $false
} |
Select -Last 1
return $result
}

View File

@@ -1,22 +1,30 @@
try
{
$package = 'SABnzbd+' $package = 'SABnzbd+'
$upgrade = $false $upgrade = $false
function Get-CurrentDirectory
{
$thisName = $MyInvocation.MyCommand.Name
[IO.Path]::GetDirectoryName((Get-Content function:$thisName).File)
}
. (Join-Path (Get-CurrentDirectory) 'WaitForSuccess.ps1')
try
{
# stop helper services if they're running # stop helper services if they're running
Get-Service -Include SABnzbd, SABHelper | Get-Service -Include SABnzbd, SABHelper |
Stop-Service -Force Stop-Service -Force
$installPath = (Join-Path "${Env:\ProgramFiles(x86)}" 'sabnzbd'), $programFilesPath = "${Env:\ProgramFiles(x86)}", $Env:ProgramFiles |
(Join-Path 'Env:ProgramFiles' 'sabnzbd') |
? { Test-Path $_ } | ? { Test-Path $_ } |
Select -First 1 Select -First 1
$helper = 'SABnzbd-helper.exe' $helper = 'SABnzbd-helper.exe'
$service = 'SABnzbd-service.exe' $service = 'SABnzbd-service.exe'
$installPath = Join-Path $programFilesPath 'sabnzbd'
# already installed, so must call remove on existing exes to be safe # already installed, so must call remove on existing exes to be safe
if ($installPath -ne $null) if (Test-Path $installPath)
{ {
$upgrade = $true $upgrade = $true
$helper, $service | $helper, $service |
@@ -37,14 +45,15 @@ try
$path = Join-Path $_[0] 'sabnzbd' $path = Join-Path $_[0] 'sabnzbd'
if (Test-Path $path) if (Test-Path $path)
{ {
Write-Host "Found SABnzbd installed at $path"
$installPath = $path $installPath = $path
$dosPath = $_[1] $dosPath = $_[1]
break
} }
} }
#register file association #register file association
#http://stackoverflow.com/questions/323426/windows-command-line-non-evaluation-of-environment-variable #http://stackoverflow.com/questions/323426/windows-command-line-non-evaluation-of-environment-variable
Write-Host "Registering SABnzbd+ NZB file associations"
cmd /c assoc .nzb=NZBFile cmd /c assoc .nzb=NZBFile
$sabPath = "^`"$dosPath\sabnzbd\SABnzbd.exe^`"" $sabPath = "^`"$dosPath\sabnzbd\SABnzbd.exe^`""
cmd /c ftype NZBFile=$sabPath `"%1`" cmd /c ftype NZBFile=$sabPath `"%1`"
@@ -52,8 +61,9 @@ try
Push-Location $installPath Push-Location $installPath
$dataDirectory = Join-Path $Env:LOCALAPPDATA 'sabnzbd' $dataDirectory = Join-Path $Env:LOCALAPPDATA 'sabnzbd'
&".\$service" -f $dataDirectory install Write-Host "Registering SABnzbd+ service with data at $dataDirectory"
&".\$helper" install &".\$service" -f $dataDirectory install | Out-Null
&".\$helper" install | Out-Null
Pop-Location Pop-Location
@@ -61,25 +71,29 @@ try
sc.exe config SABnzbd start= delayed-auto sc.exe config SABnzbd start= delayed-auto
# configure windows firewall # configure windows firewall
Write-Host "Registering SABnzbd+ firewall exclusions"
netsh advfirewall firewall delete rule name="SABnzbd+" netsh advfirewall firewall delete rule name="SABnzbd+"
netsh advfirewall firewall add rule name="SABnzbd+" dir=in protocol=tcp localport=8080 action=allow program="$installPath\SABnzbd-service.exe" netsh advfirewall firewall add rule name="SABnzbd+" dir=in protocol=tcp localport=8080 action=allow program="$installPath\SABnzbd-service.exe"
netsh advfirewall firewall add rule name="SABnzbd+" dir=in protocol=tcp localport=9090 action=allow program="$installPath\SABnzbd-service.exe" netsh advfirewall firewall add rule name="SABnzbd+" dir=in protocol=tcp localport=9090 action=allow program="$installPath\SABnzbd-service.exe"
Write-Host "Starting SABnzbd+ service"
Start-Service SABnzbd Start-Service SABnzbd
# no need to use the web UI to configure an upgrade
if ($upgrade) { return }
#wait up to 5 seconds for service to fire up #wait up to 5 seconds for service to fire up
0..10 | $msg = 'SABnzbd+ service to start, to launch browser config'
% { if (WaitForSuccess { (Get-Service SABnzbd).Status -eq 'Running' } 10 $msg)
if ((Get-Service SABnzbd).Status -eq 'Running') {
# no need to use the web UI to configure an upgrade
if (!$upgrade)
{ {
#launch local default browser to configure #launch local default browser to configure
[Diagnostics.Process]::Start('http://localhost:8080') [Diagnostics.Process]::Start('http://localhost:8080')
break
} }
Start-Sleep -Milliseconds 500 }
else
{
Write-ChocolateyFailure 'SABnzbd+ service failed to start!'
return
} }
Write-ChocolateySuccess $package Write-ChocolateySuccess $package

View File

@@ -0,0 +1,86 @@
$package = 'SABnzbd+'
function Get-CurrentDirectory
{
$thisName = $MyInvocation.MyCommand.Name
[IO.Path]::GetDirectoryName((Get-Content function:$thisName).File)
}
. (Join-Path (Get-CurrentDirectory) 'WaitForSuccess.ps1')
try
{
# stop helper services if they're running
Get-Service -Include SABnzbd, SABHelper |
Stop-Service -Force
Write-Host 'Removing Windows Firewall Exclusions'
netsh advfirewall firewall delete rule name="SABnzbd+"
$installPath = (Join-Path "${Env:\ProgramFiles(x86)}" 'sabnzbd'),
(Join-Path 'Env:ProgramFiles' 'sabnzbd') |
? { Test-Path $_ } |
Select -First 1
$helper = 'SABnzbd-helper.exe'
$service = 'SABnzbd-service.exe'
# already installed, so must call remove on existing exes to be safe
if ($installPath -ne $null)
{
Write-Host 'Removing SABnzbd+ services'
$upgrade = $true
$helper, $service |
% {
$path = Join-Path $installPath $_
if (Test-Path $path) { &$path remove }
}
}
# the above should completely remove existing services, but in case not
'SABHelper', 'SABnzbd' |
% { if (Get-Service -Include $_) { sc.exe delete $_ } }
$uninstall = Join-Path $installPath 'Uninstall.exe'
#uses NSIS installer - http://nsis.sourceforge.net/Docs/Chapter3.html
$uninstallParams = @{
PackageName = $package;
FileType = 'exe';
SilentArgs = '/S';
File = $uninstall;
}
Uninstall-ChocolateyPackage @uninstallParams
#remove file association to sabnzbd
#http://stackoverflow.com/questions/323426/windows-command-line-non-evaluation-of-environment-variable
Write-Host 'Removing SABnzbd+ NZB file associations'
$nzbRunner = cmd /c ftype NZBFile
if ($nzbRunner -match 'SABnzbd.exe')
{
cmd /c ftype NZBFile=
}
$uninstallComplete = {
(Get-Process 'uninstall' -ErrorAction SilentlyContinue) -eq $null
}
if (WaitForSuccess $uninstallComplete 10 'uninstall to complete')
{
$installPath, (Join-Path $Env:LOCALAPPDATA 'sabnzbd') |
% {
$count = (Get-ChildItem $_ -Recurse -ErrorAction SilentlyContinue).Count
if ($count -gt 0)
{
Write-Host "Remove remaining $count files from $_ manually"
}
}
}
Write-ChocolateySuccess $package
}
catch
{
Write-ChocolateyFailure $package "$($_.Exception.Message)"
throw
}