mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-01-29 17:18:38 +01:00
Updated install-calibre-server.ps1
This commit is contained in:
parent
b845d6459b
commit
725bdcb680
@ -20,34 +20,32 @@
|
||||
param([int]$port = 8099, [string]$mediaFolder = "$HOME/Calibre Library", [string]$userDB = "$HOME/CalibreUsers.sqlite", [string]$logfile = "$HOME/CalibreServer.log")
|
||||
|
||||
try {
|
||||
if ($IsLinux) {
|
||||
$stopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||
if (-not $IsLinux) { throw "Sorry, currently only supported on Linux" }
|
||||
|
||||
"⏳ (1/5) Updating package infos..."
|
||||
& sudo apt update -y
|
||||
if ($lastExitCode -ne "0") { throw "'apt update' failed" }
|
||||
$stopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||
|
||||
"⏳ (2/5) Installing Calibre..."
|
||||
& sudo apt install calibre -y
|
||||
if ($lastExitCode -ne "0") { throw "'apt install calibre' failed" }
|
||||
"⏳ (1/5) Updating package infos..."
|
||||
& sudo apt update -y
|
||||
if ($lastExitCode -ne "0") { throw "'apt update' failed" }
|
||||
|
||||
"⏳ (3/5) Searching for Calibre server executable..."
|
||||
& calibre-server --version
|
||||
if ($lastExitCode -ne "0") { throw "Can't execute 'calibre-server' - make sure Calibre server is installed and available" }
|
||||
"⏳ (2/5) Installing Calibre package..."
|
||||
& sudo apt install calibre -y
|
||||
if ($lastExitCode -ne "0") { throw "'apt install calibre' failed" }
|
||||
|
||||
"⏳ (4/5) Creating media folder at: $mediaFolder ... (if non-existent)"
|
||||
mkdir $mediaFolder
|
||||
Write-Host "⏳ (3/5) Searching for Calibre server executable... " -noNewline
|
||||
& calibre-server --version
|
||||
if ($lastExitCode -ne "0") { throw "Can't execute 'calibre-server' - make sure Calibre server is installed and available" }
|
||||
|
||||
"⏳ (5/5) Starting Calibre server as background process..."
|
||||
& calibre-server --port $port --num-per-page 100 --userdb $userDB --log $logfile --daemonize $HOME/'Calibre Library'
|
||||
"⏳ (4/5) Creating media folder at: $mediaFolder ... (if non-existent)"
|
||||
mkdir $mediaFolder
|
||||
|
||||
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
|
||||
"✔️ Installed Calibre server on Web port $port in $elapsed sec (media folder: $mediaFolder, user database: $userDB, log file: $logfile)"
|
||||
exit 0 # success
|
||||
} else {
|
||||
throw "Currently only supported on Linux"
|
||||
}
|
||||
"⏳ (5/5) Starting Calibre server as background process..."
|
||||
& calibre-server --port $port --num-per-page 100 --userdb $userDB --log $logfile --daemonize $HOME/'Calibre Library'
|
||||
|
||||
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
|
||||
"✔️ Installed Calibre server on port $port in $($elapsed)s (media at: $mediaFolder, user DB: $userDB, log to: $logfile)"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user