SickBeard - Additional installer code
- Complete uninstall script undoes configuration changes to SABNzbd - Use new WaitForSuccess helper - Wait for SickBeard to be accepting reqs before modifying config.ini - PATH and PYTHONHOME need to be set for MACHINE so that SABNzbd can find python.exe as SYSTEM to call sabToSickBeard.py - Config files should always be written as UTF8 (not Unicode or ASCII), - However, AutoProcess.cfg cannot have UTF8 BOM, so saving as ASCII - Replacing 0.0.0.0 with localhost - Support cloning into an empty Sick-Beard dir under site-packages - Minor logging tweaks - Use Season folders when sorting files - Make sure to trash processed files
This commit is contained in:
@@ -128,7 +128,7 @@ function Out-IniFile
|
|||||||
Write-Verbose "[INFO]: Out-IniFile writing file [$FilePath]"
|
Write-Verbose "[INFO]: Out-IniFile writing file [$FilePath]"
|
||||||
if ((New-Object IO.FileInfo($FilePath)).Extension -ne '.ini')
|
if ((New-Object IO.FileInfo($FilePath)).Extension -ne '.ini')
|
||||||
{
|
{
|
||||||
Write-Warning 'Out-IniFile [$FilePath] does not end in .ini extension'
|
Write-Warning "Out-IniFile [$FilePath] does not end in .ini extension"
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((Test-Path $FilePath) -and (!$Force))
|
if ((Test-Path $FilePath) -and (!$Force))
|
||||||
|
124
SickBeard/tools/chocolateyUninstall.ps1
Normal file
124
SickBeard/tools/chocolateyUninstall.ps1
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
$package = 'Sickbeard'
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
function Get-CurrentDirectory
|
||||||
|
{
|
||||||
|
$thisName = $MyInvocation.MyCommand.Name
|
||||||
|
[IO.Path]::GetDirectoryName((Get-Content function:$thisName).File)
|
||||||
|
}
|
||||||
|
|
||||||
|
# load INI parser
|
||||||
|
. (Join-Path (Get-CurrentDirectory) 'Get-IniContent.ps1')
|
||||||
|
. (Join-Path (Get-CurrentDirectory) 'Out-IniFile.ps1')
|
||||||
|
|
||||||
|
#simulate the unix command for finding things in path
|
||||||
|
#http://stackoverflow.com/questions/63805/equivalent-of-nix-which-command-in-powershell
|
||||||
|
function Which([string]$cmd)
|
||||||
|
{
|
||||||
|
Get-Command -ErrorAction "SilentlyContinue" $cmd |
|
||||||
|
Select -ExpandProperty Definition
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host 'Deleting SickBeard Windows Firewall config'
|
||||||
|
netsh advfirewall firewall delete rule name="SickBeard"
|
||||||
|
|
||||||
|
# check registry for path to sickbeard
|
||||||
|
$servicePath = 'HKLM:\SYSTEM\CurrentControlSet\Services\SickBeard\Parameters'
|
||||||
|
$installDir = Get-ItemProperty $servicePath -ErrorAction SilentlyContinue |
|
||||||
|
Select -ExpandProperty AppParameters
|
||||||
|
|
||||||
|
if ($installDir)
|
||||||
|
{
|
||||||
|
$sickBeardDir = Split-Path $installDir
|
||||||
|
$sitePackages = Split-Path $sickBeardDir
|
||||||
|
Write-Host "Found SickBeard service configuration directory of $sickBeardDir"
|
||||||
|
}
|
||||||
|
# not found - do some guesswork
|
||||||
|
else
|
||||||
|
{
|
||||||
|
# Use PYTHONHOME if it exists, or fallback to 'Where' to search PATH
|
||||||
|
if ($Env:PYTHONHOME) { $localPython = Join-Path $Env:PYTHONHOME 'python.exe' }
|
||||||
|
|
||||||
|
if (!$Env:PYTHONHOME -or !(Test-Path $localPython))
|
||||||
|
{ $localPython = Which python.exe }
|
||||||
|
|
||||||
|
if (!(Test-Path $localPython))
|
||||||
|
{
|
||||||
|
Write-Warning 'Could not find SickBeard or Python!'
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$pythonRoot = Split-Path $localPython
|
||||||
|
$sitePackages = (Join-Path (Join-Path $pythonRoot 'Lib') 'site-packages')
|
||||||
|
$sickBeardDir = Join-Path $sitePackages 'Sick-Beard'
|
||||||
|
Write-Host "SickBeard service configuration not found - assuming $sickBeardDir"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# delete the service and reg keys
|
||||||
|
if (Get-Service SickBeard -ErrorAction SilentlyContinue)
|
||||||
|
{
|
||||||
|
Write-Host 'Deleting SickBeard service'
|
||||||
|
Stop-Service SickBeard
|
||||||
|
sc.exe delete SickBeard
|
||||||
|
}
|
||||||
|
|
||||||
|
# we found Sickbeard on disk, so delete all the files
|
||||||
|
if (Test-Path $sickBeardDir)
|
||||||
|
{
|
||||||
|
Write-Host "Removing all files in $sickBeardDir"
|
||||||
|
Remove-Item $sickBeardDir -Recurse -Force -ErrorAction SilentlyContinue
|
||||||
|
if (Test-Path $sickBeardDir)
|
||||||
|
{
|
||||||
|
Write-Warning "$sickBeardDir must be deleted manually"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Read SABNzbd+ config file to delete SickBeard scripts if configured
|
||||||
|
$sabDataPath = Join-Path $Env:LOCALAPPDATA 'sabnzbd'
|
||||||
|
$sabIniPath = Join-Path $sabDataPath 'sabnzbd.ini'
|
||||||
|
if (Test-Path $sabIniPath)
|
||||||
|
{
|
||||||
|
Write-Host "Reading SABnzbd+ config file at $sabIniPath"
|
||||||
|
$sabConfig = Get-IniContent $sabIniPath
|
||||||
|
|
||||||
|
$scriptsDir = $sabConfig.misc.script_dir
|
||||||
|
# found a legit scripts dir, so delete SickBeard files
|
||||||
|
if ($scriptsDir -and ($scriptsDir -ne "`"`"") -and (Test-Path $scriptsDir))
|
||||||
|
{
|
||||||
|
Write-Host "Found SABnzbd+ script_dir $scriptsDir"
|
||||||
|
$sickbeardScripts = 'autoProcessTV.cfg', 'autoProcessTV.cfg.sample',
|
||||||
|
'autoProcessTV.py', 'hellaToSickBeard.py', 'sabToSickBeard.py'
|
||||||
|
|
||||||
|
Write-Host "Removing SickBeard scripts $sickbeardScripts"
|
||||||
|
Get-ChildItem -Path $scriptsDir -Include $sickbeardScripts -Recurse |
|
||||||
|
Remove-Item -Force
|
||||||
|
}
|
||||||
|
|
||||||
|
$tv = $sabconfig.categories.tv
|
||||||
|
if ($tv -and ($tv.script -eq 'sabToSickBeard.py'))
|
||||||
|
{
|
||||||
|
Write-Host 'Removed sabToSickBeard.py script from tv category inside SABnzbd+'
|
||||||
|
$tv.script = 'None'
|
||||||
|
$sabConfig | Out-IniFile -FilePath $sabIniPath -Force -Encoding UTF8
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host 'Restarting SABnzbd+ to accept configuration changes'
|
||||||
|
$url = ("http://localhost:$($sabConfig.misc.port)/api?mode=restart" +
|
||||||
|
"&apikey=$($sabConfig.misc.api_key)")
|
||||||
|
try
|
||||||
|
{
|
||||||
|
(New-Object Net.WebClient).DownloadString($url)
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
Write-Host "SABNzbd+ not responding to restart request"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-ChocolateySuccess $package
|
||||||
|
} catch {
|
||||||
|
Write-ChocolateyFailure $package "$($_.Exception.Message)"
|
||||||
|
throw
|
||||||
|
}
|
@@ -3,13 +3,13 @@
|
|||||||
<metadata>
|
<metadata>
|
||||||
<id>SickBeard.Source</id>
|
<id>SickBeard.Source</id>
|
||||||
<title>Sick Beard Usenet PVR</title>
|
<title>Sick Beard Usenet PVR</title>
|
||||||
<version>10.00.1600.22-Alpha</version>
|
<version>2012.10.22</version>
|
||||||
<authors>midgetspy</authors>
|
<authors>midgetspy</authors>
|
||||||
<owners>Ethan Brown</owners>
|
<owners>Ethan Brown</owners>
|
||||||
<summary>The ultimate PVR application that searches for and manages your TV shows.</summary>
|
<summary>The ultimate PVR application that searches for and manages your TV shows.</summary>
|
||||||
<description>Sick Beard is a PVR for newsgroup users (with limited torrent support). It watches for new episodes of your favorite shows and when they are posted it downloads them, sorts and renames them, and optionally generates metadata for them. It currently supports NZBs.org, NZBMatrix, NZBs'R'Us, Newzbin, Womble's Index, NZB.su, TVTorrents and EZRSS and retrieves show information from theTVDB.com and TVRage.com.
|
<description>Sick Beard is a PVR for newsgroup users (with limited torrent support). It watches for new episodes of your favorite shows and when they are posted it downloads them, sorts and renames them, and optionally generates metadata for them. It currently supports NZBs.org, NZBMatrix, NZBs'R'Us, Newzbin, Womble's Index, NZB.su, TVTorrents and EZRSS and retrieves show information from theTVDB.com and TVRage.com.
|
||||||
|
|
||||||
This package
|
This package performs a number of normally quite painful / tedious tasks
|
||||||
- Installs SABnzbd+ (compiled version)
|
- Installs SABnzbd+ (compiled version)
|
||||||
- Installs Python
|
- Installs Python
|
||||||
- Installs Cheetah with Windows optimizations
|
- Installs Cheetah with Windows optimizations
|
||||||
|
24
Sickbeard/tools/WaitForSuccess.ps1
Normal file
24
Sickbeard/tools/WaitForSuccess.ps1
Normal 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
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Start-Sleep -Milliseconds 500
|
||||||
|
}
|
||||||
|
return $false
|
||||||
|
} |
|
||||||
|
Select -Last 1
|
||||||
|
|
||||||
|
return $result
|
||||||
|
}
|
@@ -8,9 +8,9 @@ try {
|
|||||||
[IO.Path]::GetDirectoryName((Get-Content function:$thisName).File)
|
[IO.Path]::GetDirectoryName((Get-Content function:$thisName).File)
|
||||||
}
|
}
|
||||||
|
|
||||||
# load INI parser
|
|
||||||
. (Join-Path (Get-CurrentDirectory) 'Get-IniContent.ps1')
|
. (Join-Path (Get-CurrentDirectory) 'Get-IniContent.ps1')
|
||||||
. (Join-Path (Get-CurrentDirectory) 'Out-IniFile.ps1')
|
. (Join-Path (Get-CurrentDirectory) 'Out-IniFile.ps1')
|
||||||
|
. (Join-Path (Get-CurrentDirectory) 'WaitForSuccess.ps1')
|
||||||
|
|
||||||
#simulate the unix command for finding things in path
|
#simulate the unix command for finding things in path
|
||||||
#http://stackoverflow.com/questions/63805/equivalent-of-nix-which-command-in-powershell
|
#http://stackoverflow.com/questions/63805/equivalent-of-nix-which-command-in-powershell
|
||||||
@@ -20,21 +20,9 @@ try {
|
|||||||
Select -ExpandProperty Definition
|
Select -ExpandProperty Definition
|
||||||
}
|
}
|
||||||
|
|
||||||
function WaitService([string]$name, [int]$seconds)
|
$sickBeardRunning = {
|
||||||
{
|
$service = Get-Service 'SickBeard' -ErrorAction SilentlyContinue
|
||||||
Write-Host "Waiting up to $($seconds)s for $name to start..."
|
return ($service -and ($service.Status -eq 'Running'))
|
||||||
$result = 0..($seconds * 2) |
|
|
||||||
% {
|
|
||||||
$service = Get-Service $name -ErrorAction SilentlyContinue
|
|
||||||
if ($service -and ($service.Status -eq 'Running'))
|
|
||||||
{ return $true }
|
|
||||||
elseif ($service)
|
|
||||||
{ Start-Sleep -Milliseconds 500 }
|
|
||||||
return $false
|
|
||||||
} |
|
|
||||||
Select -Last 1
|
|
||||||
|
|
||||||
return $result
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Use PYTHONHOME if it exists, or fallback to 'Where' to search PATH
|
# Use PYTHONHOME if it exists, or fallback to 'Where' to search PATH
|
||||||
@@ -51,6 +39,17 @@ try {
|
|||||||
|
|
||||||
$pythonRoot = Split-Path $localPython
|
$pythonRoot = Split-Path $localPython
|
||||||
|
|
||||||
|
# as we're running a service as SYSTEM, Machine needs python in PATH
|
||||||
|
# TODO: Bug in Install-ChocolateyPath won't add to MACHINE if already in USER
|
||||||
|
$setMachinePathScript = @"
|
||||||
|
`$vars = [Environment]::GetEnvironmentVariable('PATH', 'Machine') -split ';';
|
||||||
|
if (!(`$vars -contains '$pythonRoot')) { `$vars += '$pythonRoot' };
|
||||||
|
[Environment]::SetEnvironmentVariable('PATH', (`$vars -join ';'), 'Machine');
|
||||||
|
[Environment]::SetEnvironmentVariable('PYTHONHOME', '$pythonRoot', 'Machine');
|
||||||
|
"@
|
||||||
|
|
||||||
|
Start-ChocolateyProcessAsAdmin $setMachinePathScript
|
||||||
|
|
||||||
$sitePackages = (Join-Path (Join-Path $pythonRoot 'Lib') 'site-packages')
|
$sitePackages = (Join-Path (Join-Path $pythonRoot 'Lib') 'site-packages')
|
||||||
if (!(Test-Path $sitePackages))
|
if (!(Test-Path $sitePackages))
|
||||||
{
|
{
|
||||||
@@ -62,14 +61,20 @@ try {
|
|||||||
Push-Location $sitePackages
|
Push-Location $sitePackages
|
||||||
$git = Which git
|
$git = Which git
|
||||||
$sickBeardPath = (Join-Path $sitePackages 'Sick-Beard')
|
$sickBeardPath = (Join-Path $sitePackages 'Sick-Beard')
|
||||||
|
$sickBeardEmpty = $true
|
||||||
if (Test-Path $sickBeardPath)
|
if (Test-Path $sickBeardPath)
|
||||||
|
{
|
||||||
|
$files = Get-ChildItem $sickBeardPath -Recurse -ErrorAction SilentlyContinue
|
||||||
|
$sickBeardEmpty = ($files.Count -eq 0)
|
||||||
|
}
|
||||||
|
if (!$sickBeardEmpty)
|
||||||
{
|
{
|
||||||
Write-ChocolateySuccess 'SickBeard already installed!'
|
Write-ChocolateySuccess 'SickBeard already installed!'
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Write-ChocolateySuccess 'Cloning SickBeard source from GitHub'
|
Write-Host 'Cloning SickBeard source from GitHub'
|
||||||
&git clone https://github.com/midgetspy/Sick-Beard
|
&git clone https://github.com/midgetspy/Sick-Beard
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,7 +84,7 @@ try {
|
|||||||
if (Test-Path $sabIniPath)
|
if (Test-Path $sabIniPath)
|
||||||
{
|
{
|
||||||
Write-Host "Reading SABnzbd+ config file at $sabIniPath"
|
Write-Host "Reading SABnzbd+ config file at $sabIniPath"
|
||||||
$sabConfig = Get-IniContent $sabIniPath
|
$sabConfig = Get-IniContent -Path $sabIniPath
|
||||||
|
|
||||||
# 3 options - missing script_dir, script_dir set to "", or configured script_dir
|
# 3 options - missing script_dir, script_dir set to "", or configured script_dir
|
||||||
if (!$sabConfig.misc.script_dir -or `
|
if (!$sabConfig.misc.script_dir -or `
|
||||||
@@ -88,12 +93,12 @@ try {
|
|||||||
$scriptDir = (Join-Path $sabDataPath 'scripts')
|
$scriptDir = (Join-Path $sabDataPath 'scripts')
|
||||||
Write-Host "Configured SABnzbd+ script_dir to $scriptDir"
|
Write-Host "Configured SABnzbd+ script_dir to $scriptDir"
|
||||||
$sabConfig.misc.script_dir = $scriptDir
|
$sabConfig.misc.script_dir = $scriptDir
|
||||||
$sabConfig | Out-IniFile -FilePath $sabIniPath -Force
|
$sabConfig | Out-IniFile -FilePath $sabIniPath -Force -Encoding UTF8
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(Test-Path $sabConfig.misc.script_dir))
|
if (!(Test-Path $sabConfig.misc.script_dir))
|
||||||
{
|
{
|
||||||
[Void]New-Item -Path $sabConfig.misc.script_dir -Type Directory
|
New-Item -Path $sabConfig.misc.script_dir -Type Directory | Out-Null
|
||||||
}
|
}
|
||||||
|
|
||||||
# copy and configure autoprocessing scripts in SABNzbd+ scripts directory
|
# copy and configure autoprocessing scripts in SABNzbd+ scripts directory
|
||||||
@@ -123,7 +128,7 @@ try {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Write-Host 'Configured tv category in SABnzbd+'
|
Write-Host 'Configured tv category in SABnzbd+'
|
||||||
$sabConfig | Out-IniFile -FilePath $sabIniPath -Force
|
$sabConfig | Out-IniFile -FilePath $sabIniPath -Force -Encoding UTF8
|
||||||
}
|
}
|
||||||
|
|
||||||
# regardless of sabnzbd+ install status, .PY should be executable
|
# regardless of sabnzbd+ install status, .PY should be executable
|
||||||
@@ -147,7 +152,7 @@ try {
|
|||||||
Write-Host "Found resource kit - registering SickBeard as a service"
|
Write-Host "Found resource kit - registering SickBeard as a service"
|
||||||
Push-Location $resourceKit
|
Push-Location $resourceKit
|
||||||
$srvAny = Join-Path $resourceKit 'srvany.exe'
|
$srvAny = Join-Path $resourceKit 'srvany.exe'
|
||||||
.\instsrv SickBeard $srvany
|
.\instsrv SickBeard $srvany | Out-Null
|
||||||
|
|
||||||
# Set-Service cmdlet doesn't have depend OR delayed start :(
|
# Set-Service cmdlet doesn't have depend OR delayed start :(
|
||||||
Write-Host "Configuring service delayed auto with Tcpip dependency"
|
Write-Host "Configuring service delayed auto with Tcpip dependency"
|
||||||
@@ -171,12 +176,34 @@ try {
|
|||||||
Start-Service SickBeard
|
Start-Service SickBeard
|
||||||
|
|
||||||
# config files are created on first start-up
|
# config files are created on first start-up
|
||||||
if (WaitService 'SickBeard', 20)
|
$configPath = (Join-Path $sickBeardPath 'config.ini')
|
||||||
{
|
|
||||||
$configPath = (Join-Path $sickBeardPath 'config.ini')
|
|
||||||
$sickBeardConfig = Get-IniContent $configPath
|
|
||||||
|
|
||||||
Write-Host "Configuring Windows Firewall for the SickBeard port"
|
# to start hacking config.ini the service needs to be up, config.ini needs
|
||||||
|
# to exist, and SickBeard must respond to requests (config.ini is complete)
|
||||||
|
$waitOnConfig = {
|
||||||
|
if (!(&$sickBeardRunning)) { return $false }
|
||||||
|
if (!(Test-Path $configPath)) { return $false }
|
||||||
|
|
||||||
|
# fails with a 200 (unknown API key) so we know it's accepting requests!
|
||||||
|
$pingUrl = 'http://localhost:8081/api/?cmd=sb.ping'
|
||||||
|
try
|
||||||
|
{
|
||||||
|
(New-Object Net.WebClient).DownloadString($pingUrl)
|
||||||
|
return $true
|
||||||
|
}
|
||||||
|
catch {}
|
||||||
|
|
||||||
|
return $false
|
||||||
|
}
|
||||||
|
|
||||||
|
if (WaitForSuccess $waitOnConfig 20 'SickBeard to start and create config')
|
||||||
|
{
|
||||||
|
Write-Host 'SickBeard started and configuration files created'
|
||||||
|
$sickBeardConfig = Get-IniContent -Path $configPath
|
||||||
|
|
||||||
|
$sickBeardApiKey = $sickBeardConfig.General.api_key
|
||||||
|
|
||||||
|
Write-Host 'Configuring Windows Firewall for the SickBeard port'
|
||||||
# configure windows firewall
|
# configure windows firewall
|
||||||
netsh advfirewall firewall delete rule name="SickBeard"
|
netsh advfirewall firewall delete rule name="SickBeard"
|
||||||
# program="$pythonW"
|
# program="$pythonW"
|
||||||
@@ -191,7 +218,9 @@ try {
|
|||||||
$sickBeardConfig.General.move_associated_files = 1
|
$sickBeardConfig.General.move_associated_files = 1
|
||||||
$sickBeardConfig.General.api_key = [Guid]::NewGuid().ToString('n')
|
$sickBeardConfig.General.api_key = [Guid]::NewGuid().ToString('n')
|
||||||
$sickBeardConfig.General.metadata_xbmc = '1|1|1|1|1|1'
|
$sickBeardConfig.General.metadata_xbmc = '1|1|1|1|1|1'
|
||||||
$sickBeardConfig.General.naming_pattern = '%SN - %Sx%0E - %EN'
|
$sickBeardConfig.General.keep_processed_dir = 0
|
||||||
|
|
||||||
|
$sickBeardConfig.General.naming_pattern = 'Season %S\%SN - %Sx%0E - %EN'
|
||||||
#range like x03-05
|
#range like x03-05
|
||||||
$sickBeardConfig.General.naming_multi_ep = 8
|
$sickBeardConfig.General.naming_multi_ep = 8
|
||||||
|
|
||||||
@@ -210,30 +239,33 @@ try {
|
|||||||
$sickBeardConfig.SABnzbd.sab_category = 'tv'
|
$sickBeardConfig.SABnzbd.sab_category = 'tv'
|
||||||
$sickBeardConfig.SABnzbd.sab_host = "http://localhost:$($sabConfig.misc.port)/"
|
$sickBeardConfig.SABnzbd.sab_host = "http://localhost:$($sabConfig.misc.port)/"
|
||||||
|
|
||||||
$sickBeardConfig | Out-IniFile -File $configPath -Force -Encoding ASCII
|
$sickBeardConfig |
|
||||||
|
Out-IniFile -File $configPath -Force -Encoding UTF8 |
|
||||||
|
Out-Null
|
||||||
|
|
||||||
Stop-Service SickBeard
|
Restart-Service SickBeard
|
||||||
Start-Service SickBeard
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$autoConfig = Join-Path $sabConfig.misc.script_dir 'autoProcessTV.cfg'
|
$autoConfig = Join-Path $sabConfig.misc.script_dir 'autoProcessTV.cfg'
|
||||||
if (!(Test-Path $autoConfig))
|
if (!(Test-Path $autoConfig))
|
||||||
{
|
{
|
||||||
$processConfig = @{
|
# order shouldn't matter, but don't trust Python ;0
|
||||||
'SickBeard' = @{
|
$sbAuto = New-Object Collections.Specialized.OrderedDictionary
|
||||||
host = $sickBeardConfig.General.web_host;
|
$sbAuto.host = $sickBeardConfig.General.web_host -replace '0\.0\.0\.0',
|
||||||
port = $sickBeardConfig.General.web_port;
|
'localhost';
|
||||||
username = $sickBeardConfig.General.web_username;
|
$sbAuto.port = $sickBeardConfig.General.web_port;
|
||||||
password = $sickBeardConfig.General.web_password;
|
$sbAuto.username = $sickBeardConfig.General.web_username;
|
||||||
web_root = $sickBeardConfig.General.web_root;
|
$sbAuto.password = $sickBeardConfig.General.web_password;
|
||||||
ssl = 0;
|
$sbAuto.web_root = $sickBeardConfig.General.web_root;
|
||||||
}
|
$sbAuto.ssl = 0;
|
||||||
}
|
|
||||||
$processConfig | Out-IniFile -FilePath $autoConfig
|
@{ 'SickBeard' = $sbAuto } |
|
||||||
|
Out-IniFile -FilePath $autoConfig -Encoding ASCII -Force
|
||||||
|
|
||||||
Write-Host @"
|
Write-Host @"
|
||||||
SickBeard SABNzbd+ post-processing scripts configured
|
SickBeard SABNzbd+ post-processing scripts configured
|
||||||
If SickBeard is reconfigured with a username or password or another
|
If SickBeard is reconfigured with a username or password or another
|
||||||
host then those same changes must be made to $sickBeardConfig
|
host then those same changes must be made to $configPath
|
||||||
"@
|
"@
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,12 +275,15 @@ SickBeard SABNzbd+ post-processing scripts configured
|
|||||||
(New-Object Net.WebClient).DownloadString($url)
|
(New-Object Net.WebClient).DownloadString($url)
|
||||||
|
|
||||||
#wait up to 5 seconds for service to fire up
|
#wait up to 5 seconds for service to fire up
|
||||||
if (WaitService 'SickBeard' 5)
|
if (WaitForSuccess $sickBeardRunning 5 'SickBeard to start')
|
||||||
{
|
{
|
||||||
#launch local default browser for additional config
|
#launch local default browser for additional config
|
||||||
[Diagnostics.Process]::Start("http://localhost:$($sickBeardConfig.General.web_port)")
|
$configUrl = "http://localhost:$($sickBeardConfig.General.web_port)"
|
||||||
|
[Diagnostics.Process]::Start($configUrl) | Out-Null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Write-Host "For use in other apps, SickBeard API key: $sickBeardApiKey"
|
||||||
|
|
||||||
Pop-Location
|
Pop-Location
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user