PowerShell/Docs/install-calibre-server.md

109 lines
3.2 KiB
Markdown
Raw Normal View History

2023-07-29 10:34:04 +02:00
*install-calibre-server.ps1*
================
2023-05-26 12:20:18 +02:00
This PowerShell script installs and starts a local Calibre server as background process (using Web port 8099 by default).
2023-07-29 10:04:38 +02:00
Parameters
----------
2023-05-26 12:20:18 +02:00
```powershell
2023-07-29 10:15:44 +02:00
PS> ./install-calibre-server.ps1 [[-Port] <Int32>] [[-UserDB] <String>] [[-Logfile] <String>] [<CommonParameters>]
2023-05-26 12:20:18 +02:00
-Port <Int32>
Specifies the Web port number (8099 by default)
Required? false
Position? 1
Default value 8099
Accept pipeline input? false
Accept wildcard characters? false
-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
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
```
2023-07-29 10:04:38 +02:00
Example
-------
2023-05-26 12:20:18 +02:00
```powershell
2023-08-06 21:36:33 +02:00
PS> ./install-calibre-server.ps1
2023-05-26 12:20:18 +02:00
```
2023-07-29 10:04:38 +02:00
Notes
-----
2023-05-26 12:20:18 +02:00
Author: Markus Fleschutz | License: CC0
2023-07-29 10:04:38 +02:00
Related Links
-------------
2023-05-26 12:20:18 +02:00
https://github.com/fleschutz/PowerShell
2023-07-29 10:04:38 +02:00
Script Content
--------------
2023-05-26 12:20:18 +02:00
```powershell
<#
.SYNOPSIS
Installs Calibre server (needs admin rights)
.DESCRIPTION
This PowerShell script installs and 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
2023-08-06 21:36:33 +02:00
PS> ./install-calibre-server.ps1
2023-05-26 12:20:18 +02:00
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
#Requires -RunAsAdministrator
param([int]$Port = 8099, [string]$UserDB = "$HOME/CalibreUsers.sqlite", [string]$Logfile = "$HOME/CalibreServer.log")
try {
$StopWatch = [system.diagnostics.stopwatch]::startNew()
"⏳ (1/5) Updating package infos..."
& sudo apt update -y
if ($lastExitCode -ne "0") { throw "'apt update' failed" }
"⏳ (2/5) Installing the Calibre package..."
& sudo apt install calibre -y
if ($lastExitCode -ne "0") { throw "'apt install calibre' 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" }
"⏳ (4/5) Creating folder 'Calibre Library' in your home directory..."
mkdir $HOME/'Calibre Library'
"⏳ (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 in $Elapsed sec (Web port $Port, user DB at $UserDB, log file at $Logfile)"
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}
```
2023-10-19 08:12:00 +02:00
*(generated by convert-ps2md.ps1 using the comment-based help of install-calibre-server.ps1 as of 10/19/2023 08:11:38)*