View Single Post
Old 11-15-2021, 03:54 AM   #14
gpm
Member
gpm began at the beginning.
 
gpm's Avatar
 
Posts: 12
Karma: 40
Join Date: Jan 2017
Device: Pocketbook, Tolino, Sony
The upgrade is now simpler. Raspberry OS 'Bullseye' is officially released.
----------------------------


Read Kovids help file:
https://manual.calibre-ebook.com/ind...content-server
and:
https://manual.calibre-ebook.com/gen...re-server.html
----------------------------

install calibre:

Code:
sudo su
apt update
apt install calibre
----------------------------

Create a service file for systemd
(adapt to your needs):

/etc/systemd/system/calibre-server.service:

Code:
[Unit]
Description=calibre content server
After=network.target

[Service]
Type=simple
PIDFile=/home/pi/.calibre-server.pid
User=pi
Group=pi
ExecStart=/usr/bin/calibre-server \
 --listen-on 0.0.0.0 \
 --enable-auth \
 --auth-mode=basic \
 --port=8081 \
 --pidfile=/home/pi/.calibre-server.pid \
 --userdb="/home/pi/.config/calibre/server-users.sqlite" \
 "/home/pi/MyBooks(Pi)"

Restart=on-failure

[Install]
WantedBy=multi-user.target
----------------------------

To start calibre-server at system start:
Code:
sudo systemctl enable calibre-server
To start calibre-server:
Code:
sudo systemctl start calibre-server
----------------------------

Now, as you're running, what about to start the
calibre GUI with this very library?
You have to stop the calibre-server first, there can't
be multi user access to the library = data bank.

Therefore I made a dektop icon to start the calibre Gui.
It stops the calibre-server, runs the GUI and restarts the
server after closing the GUI.

There are two parts.

1) A script which does what is needed:

StartCalibreGUI:

Code:
#!/bin/sh
USER='pi'
SERVICE='calibre-server'
PID_FILE=/home/pi/.calibre-server.pid
# we need to stop $SERVICE before
# running the GUI
if [ -f $PID_FILE ]; then
    sudo systemctl stop $SERVICE
elif pgrep -f $SERVICE >/dev/null; then
    sudo systemctl stop $SERVICE
else
    echo "\n  $SERVICE was not running"
fi

# start calibre GUI
/usr/bin/calibre

# after terminating the GUI
# restart $SERVICE
sudo systemctl start $SERVICE

if [ $? -eq 0 ]; then
    exit 0
    echo "$SERVICE was restarted"
else
    echo  "\n  FAIL - $SERVICE is NOT running."
    echo "  Something went wrong."
    sleep 30
    exit 1
fi
----------------------------

2) A desktop icon which represents:

/home/pi/Desktop/!calibre!.desktop:
Code:
[Desktop Entry]
Type=Link
Name=! Calibre !
Icon=calibre-gui
# opens a terminal window to see whats going on
# working-dir: where the start script (StartCalibreGui) is
Exec=lxterminal -t "starting calibre GUI..." --working-directory=/home/pi/.scripts/ -e StartCalibreGUI
Type=Application
Encoding=UTF-8
Terminal=false
Comment=stops calibre server and restarts after closing the GUI
StartupNotify=true
----------------------------


You may have similar shortcuts on your Windows desktop - as I have
on my Windows DT to achieve the same result: Close the
calibre-server before opening the Calibre GUI and restart
the server after closing the GUI:


CalibreStopStart.cmd:
Code:
@echo off
set PATH=D:\PortableApps\portable_putty;%PATH%

plink.exe -batch -i "G:\my\Eigene Dateien\PuttyPrivate.ppk" -P 22 pi@192.168.178.18 /home/pi/.scripts/StopStartCalibreServer stop

REM Start Calibre GUI
"W:\Calibre Portable\calibre-portable.exe" 

echo(
echo   *****************************************
echo   *****************************************
echo   ***                                   ***
echo   ***    Calibre GUI is now RUNNING!    ***
echo   ***                                   ***
echo   *****************************************
echo   *****************************************
echo(
echo   To restart the content server & echo(
echo   *** terminate Calibre GUI *** & echo(
echo   and hit any key. & echo(

PAUSE >nul
echo   Starting...

plink.exe -batch Rasp_StartStopCalibreSrv
gpm is offline   Reply With Quote