mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-04-23 10:28:23 +02:00
Update start-calibre-server.ps1
This commit is contained in:
parent
39d17bbf49
commit
0e4a6036f2
@ -1,8 +1,8 @@
|
|||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Starts a local Calibre server
|
Starts a Calibre server
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script starts a local Calibre server as background process (Web port number is 8099 by default).
|
This PowerShell script starts a local Calibre server as background process (using Web port 8099 by default).
|
||||||
.PARAMETER port
|
.PARAMETER port
|
||||||
Specifies the Web port number (8099 by default)
|
Specifies the Web port number (8099 by default)
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
@ -10,23 +10,24 @@
|
|||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
Author: Markus Fleschutz / License: CC0
|
Author: Markus Fleschutz | License: CC0
|
||||||
#>
|
#>
|
||||||
|
|
||||||
param([int]$port = 8099)
|
param([int]$Port = 8099, [string]$UserDB = "$HOME/CalibreUsers.sqlite", [string]$Logfile = "$HOME/CalibreServer.log")
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$StopWatch = [system.diagnostics.stopwatch]::startNew()
|
$StopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||||
|
|
||||||
"Step 1/2: Searching for Calibre server executable..."
|
"⏳ Step 1/2: Searching for Calibre server executable..."
|
||||||
& calibre-server --version
|
& calibre-server --version
|
||||||
if ($lastExitCode -ne "0") { throw "Can't execute 'calibre-server' - make sure Calibre server is installed and available" }
|
if ($lastExitCode -ne "0") { throw "Can't execute 'calibre-server' - make sure Calibre server is installed and available" }
|
||||||
|
|
||||||
"Step 2/2: Starting Calibre server as background process..."
|
"⏳ Step 2/2: Starting Calibre server..."
|
||||||
& calibre-server --port $port --num-per-page 100 --userdb $HOME/CalibreUsers.sqlite --log $HOME/CalibreServer.log --daemonize $HOME/'Calibre Library'
|
" configured is Web port: $Port, user DB: $UserDB, log file: $Logfile"
|
||||||
|
& calibre-server --port $Port --num-per-page 100 --userdb $UserDB --log $Logfile --daemonize $HOME/'Calibre Library'
|
||||||
|
|
||||||
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
||||||
"✔️ started Calibre server with port $port in $Elapsed sec"
|
"✔️ started Calibre server as background process in $Elapsed sec"
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
Loading…
Reference in New Issue
Block a user