PowerShell/docs/start-calibre-server.md

91 lines
2.7 KiB
Markdown
Raw Permalink Normal View History

2022-12-04 10:40:18 +01:00
## The *start-calibre-server.ps1* Script
2021-11-08 21:36:42 +01:00
2022-11-17 19:46:02 +01:00
This PowerShell script starts a local Calibre server as background process (using Web port 8099 by default).
2021-11-08 21:36:42 +01:00
## Parameters
```powershell
2022-11-17 19:46:02 +01:00
start-calibre-server.ps1 [[-Port] <Int32>] [[-UserDB] <String>] [[-Logfile] <String>] [<CommonParameters>]
2021-11-08 21:36:42 +01:00
2022-11-17 19:46:02 +01:00
-Port <Int32>
2021-11-08 21:36:42 +01:00
Specifies the Web port number (8099 by default)
Required? false
Position? 1
Default value 8099
Accept pipeline input? false
Accept wildcard characters? false
2022-11-17 19:46:02 +01:00
-UserDB <String>
Required? false
Position? 2
Default value "$HOME/CalibreUsers.sqlite"
Accept pipeline input? false
Accept wildcard characters? false
-Logfile <String>
Required? false
Position? 3
Default value "$HOME/CalibreServer.log"
Accept pipeline input? false
Accept wildcard characters? false
2021-11-08 21:36:42 +01:00
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
```
## Example
```powershell
PS> ./start-calibre-server
```
## Notes
2022-11-17 19:46:02 +01:00
Author: Markus Fleschutz | License: CC0
2021-11-08 21:36:42 +01:00
## Related Links
https://github.com/fleschutz/PowerShell
2022-11-17 20:02:26 +01:00
## Source Code
2022-11-17 20:05:34 +01:00
```powershell
2022-11-17 20:02:26 +01:00
<#
.SYNOPSIS
Starts a Calibre server
.DESCRIPTION
This PowerShell script starts a local Calibre server as background process (using Web port 8099 by default).
.PARAMETER port
Specifies the Web port number (8099 by default)
.EXAMPLE
PS> ./start-calibre-server
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
param([int]$Port = 8099, [string]$UserDB = "$HOME/CalibreUsers.sqlite", [string]$Logfile = "$HOME/CalibreServer.log")
try {
$StopWatch = [system.diagnostics.stopwatch]::startNew()
"⏳ Step 1/2 - 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" }
"⏳ Step 2/2 - Starting Calibre server as background process..."
" (Web port $Port, user DB at $UserDB, log file at $Logfile)"
& calibre-server --port $Port --num-per-page 100 --userdb $UserDB --log $Logfile --daemonize $HOME/'Calibre Library'
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
"✔️ started Calibre server in $Elapsed sec"
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}
2022-11-17 20:05:34 +01:00
```
2022-11-17 20:02:26 +01:00
2021-11-08 21:36:42 +01:00
*Generated by convert-ps2md.ps1 using the comment-based help of start-calibre-server.ps1*