Rename to install-calibre-server.ps1

This commit is contained in:
Markus Fleschutz 2023-04-06 09:04:27 +02:00
parent 0857703870
commit a97064c0ef
2 changed files with 17 additions and 8 deletions

View File

@ -1,33 +1,42 @@
<# <#
.SYNOPSIS .SYNOPSIS
Starts a Calibre server Installs a Calibre server (needs admin rights)
.DESCRIPTION .DESCRIPTION
This PowerShell script starts a local Calibre server as background process (using Web port 8099 by default). This PowerShell script installs and 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
PS> ./start-calibre-server PS> ./install-calibre-server
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES
Author: Markus Fleschutz | License: CC0 Author: Markus Fleschutz | License: CC0
#> #>
#Requires -RunAsAdministrator
param([int]$Port = 8099, [string]$UserDB = "$HOME/CalibreUsers.sqlite", [string]$Logfile = "$HOME/CalibreServer.log") 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..." "⏳ (1/4) Updating package infos..."
& sudo apt update -y
if ($lastExitCode -ne "0") { throw "'apt update' failed" }
"⏳ (2/4) Installing the Calibre package..."
& sudo apt install calibre -y
if ($lastExitCode -ne "0") { throw "'apt install calibre' failed" }
"⏳ (3/4) 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..." "⏳ (4/4) 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' & 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 in $Elapsed sec" "✔️ installed Calibre in $Elapsed sec (Web port $Port, user DB at $UserDB, log file at $Logfile)"
exit 0 # success exit 0 # success
} catch { } catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -20,7 +20,7 @@ try {
& sudo apt update -y & sudo apt update -y
if ($lastExitCode -ne "0") { throw "'apt update' failed" } if ($lastExitCode -ne "0") { throw "'apt update' failed" }
"⏳ (2/10) Installing the Unbound package..." "⏳ (2/10) Installing the Unbound packages..."
& sudo apt install unbound unbound-anchor -y & sudo apt install unbound unbound-anchor -y
if ($lastExitCode -ne "0") { throw "'apt install unbound' failed" } if ($lastExitCode -ne "0") { throw "'apt install unbound' failed" }