diff --git a/Data/scripts.csv b/Data/scripts.csv index ed8eac69..6fe0a937 100644 --- a/Data/scripts.csv +++ b/Data/scripts.csv @@ -184,6 +184,7 @@ speak-joke.ps1, speaks the next joke by text-to-speech (TTS) speak-test.ps1, performs a speak test by text-to-speech (TTS) speak-text.ps1, speaks the given text by text-to-speech (TTS) speak-time.ps1, speaks the current time by text-to-speech (TTS) +start-calibre-server.ps1, starts a local Calibre server start-ipfs-server.ps1, starts a local IPFS server switch-branch.ps1, switches the branch in the current/given Git repository (including submodules) switch-shelly1.ps1, switches a Shelly1 device in the local network diff --git a/README.md b/README.md index d01f3b88..f81f9972 100644 --- a/README.md +++ b/README.md @@ -221,6 +221,7 @@ Mega Collection of PowerShell Scripts * [set-timer.ps1](Scripts/set-timer.ps1) - sets a timer for a countdown * [simulate-matrix.ps1](Scripts/simulate-matrix.ps1) - simulates the Matrix (fun) * [simulate-presence.ps1](Scripts/simulate-presence.ps1) - simulates the human presence against burglars +* [start-calibre-server.ps1](Scripts/start-calibre-server.ps1) - starts a local Calibre server * [start-ipfs-server.ps1](Scripts/start-ipfs-server.ps1) - starts a local IPFS server * [switch-shelly1.ps1](Scripts/switch-shelly1.ps1) - switches a Shelly1 device in the local network * [translate-file.ps1](Scripts/translate-file.ps1) - translates the given text file into other languages diff --git a/Scripts/calibre-server.sh b/Scripts/calibre-server.sh deleted file mode 100755 index 8507fe78..00000000 --- a/Scripts/calibre-server.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -# Syntax: ./calibre-server -# Description: starts a Calibre server -# Author: Markus Fleschutz -# Source: github.com/fleschutz/PowerShell -# License: CC0 - -echo "Starting Calibre Server ..." -calibre-server --port 8099 --num-per-page 100 --userdb $HOME/CalibreUsers.sqlite --log $HOME/CalibreServer.log --daemonize $HOME/'Calibre Library' -echo "OK - Calibre Server started." -exit 0 diff --git a/Scripts/start-calibre-server.ps1 b/Scripts/start-calibre-server.ps1 new file mode 100755 index 00000000..dadf1862 --- /dev/null +++ b/Scripts/start-calibre-server.ps1 @@ -0,0 +1,28 @@ +<# +.SYNOPSIS + start-calibre-server.ps1 +.DESCRIPTION + Starts a local Calibre server as a daemon process +.EXAMPLE + PS> .\start-calibre-server.ps1 +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz / License: CC0 +#> + +try { + $StopWatch = [system.diagnostics.stopwatch]::startNew() + + $Result = (calibre-server --version) + if ($lastExitCode -ne "0") { throw "Can't execute 'calibre-server' - make sure Calibre is installed and available" } + + & calibre-server --port 8099 --num-per-page 100 --userdb $HOME/CalibreUsers.sqlite --log $HOME/CalibreServer.log --daemonize $HOME/'Calibre Library' + + [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds + "✔️ started Calibre Server in $Elapsed sec" + exit 0 +} catch { + write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +}