The *install-calibre-server.ps1* Script =========================== This PowerShell script installs and starts a local Calibre server as background process. Parameters ---------- ```powershell /Repos/PowerShell/scripts/install-calibre-server.ps1 [[-port] ] [[-mediaFolder] ] [[-userDB] ] [[-logfile] ] [] -port Specifies the Web port number (8099 by default) Required? false Position? 1 Default value 8099 Accept pipeline input? false Accept wildcard characters? false -mediaFolder Specifies the file path to the media ('/opt/Calibre Library' by default) Required? false Position? 2 Default value /opt/Calibre Library Accept pipeline input? false Accept wildcard characters? false -userDB Specifies the file path to the user database ('/opt/CalibreUsers.sqlite' by default) Required? false Position? 3 Default value /opt/CalibreUsers.sqlite Accept pipeline input? false Accept wildcard characters? false -logfile Specifies the file path to the log file ('/opt/CalibreServer.log' by default) Required? false Position? 4 Default value /opt/CalibreServer.log Accept pipeline input? false Accept wildcard characters? false [] This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, WarningVariable, OutBuffer, PipelineVariable, and OutVariable. ``` Example ------- ```powershell PS> ./install-calibre-server.ps1 ⏳ (1/5) Updating package infos... ... ``` Notes ----- Author: Markus Fleschutz | License: CC0 Related Links ------------- https://github.com/fleschutz/PowerShell Script Content -------------- ```powershell <# .SYNOPSIS Installs the Calibre server (needs admin rights) .DESCRIPTION This PowerShell script installs and starts a local Calibre server as background process. .PARAMETER port Specifies the Web port number (8099 by default) .PARAMETER mediaFolder Specifies the file path to the media ('/opt/Calibre Library' by default) .PARAMETER userDB Specifies the file path to the user database ('/opt/CalibreUsers.sqlite' by default) .PARAMETER logfile Specifies the file path to the log file ('/opt/CalibreServer.log' by default) .EXAMPLE PS> ./install-calibre-server.ps1 ⏳ (1/5) Updating package infos... ... .LINK https://github.com/fleschutz/PowerShell .NOTES Author: Markus Fleschutz | License: CC0 #> #Requires -RunAsAdministrator param([int]$port = 8099, [string]$mediaFolder = "/opt/Calibre Library", [string]$userDB = "/opt/CalibreUsers.sqlite", [string]$logfile = "/opt/CalibreServer.log") try { if (-not $IsLinux) { throw "Sorry, currently only supported on Linux" } $stopWatch = [system.diagnostics.stopwatch]::startNew() "`n⏳ (1/5) Updating package infos..." & sudo apt update -y if ($lastExitCode -ne "0") { throw "'apt update' failed" } "`n⏳ (2/5) Installing Calibre package..." & sudo apt install calibre -y if ($lastExitCode -ne "0") { throw "'apt install calibre' failed" } "`n⏳ (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" } "`n⏳ (4/5) Creating media folder at: $mediaFolder ... (if non-existent)" & mkdir $mediaFolder "`n⏳ (5/5) Starting Calibre server as background process..." & sudo calibre-server --port $port --num-per-page 100 --userdb $userDB --log $logfile --daemonize $mediaFolder [int]$elapsed = $stopWatch.Elapsed.TotalSeconds "✅ Installed and started Calibre server on port $port in $($elapsed)s." " (media at: $mediaFolder, user DB: $userDB, logging to: $logfile)" exit 0 # success } catch { "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" exit 1 } ``` *(page generated by convert-ps2md.ps1 as of 01/23/2025 12:15:21)*