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