Alien Pastures

My thoughts on Slackware, life and everything

Page 36 of 176

How to access your e-books online

In a previous article about the Calibre e-book library management program, I wrote that I did away with USB cable connections to transfer e-books from my Calibre library to my E-reader. Instead, I made my e-book library accessible on-line and now I am able to download my books securely over the Internet – no matter where I am, as long as I have a network connection.

In this article today, I am going to explain how I make my Calibre library accessible on-line.

Understandably, the article will be Slackware-centric, because that is where I have my Calibre library and where I run all the programs that I need. But, the technology and the configuration is generic enough that readers of this article running another distro or even employing an embedded (ARM) device will be able to make it work.

Which software is used?

Apache and PHP are standard part of Slackware Linux. I assume that you know how to setup an Apache web server. The good news is that Slackware’s default httpd configuration works out of the box. However, it does not enable a secure (https) web site. That part is on you.
If your content server is going to be used in your home network only, then HTTPS is not even needed.
I have a package for Calibre in my repository which of course you will definitely need if you want to build an e-book library.
You’ll have to download the ZIP file of the latest COPS release from https://github.com/seblucas/cops/releases – the ZIP contains the extra stuff that is not contained in the source .tar.gz file.
The remainder is just configuration.

Now let me explain my setup.

The Calibre library

It all starts with Calibre of course. It is a desktop program, available for Linux, Windows and MacOS. It stores your e-book library as a directory tree.  The directories immediately below the root of the tree are the book authors. In the root of the directory tree, Calibre creates a SQLite database file containing all the library metadata. The simple directory structure and the SQLite database file make that a Calibre library is independent of the Operating System that Calibre runs on. Its database scheme can be updated between major releases though. From within the Calibre GUI, it is however trivial to re-create this database file from scratch if it becomes corrupted.
This simple library setup has the advantage that if you store the library on a Cloud service like Dropbox, you can have access to your library from multiple computers running different Operating Systems (but preferably all the same version of Calibre). As long as one person accesses the library at any time, the Calibre database file will not get corrupted. This is how I have setup Calibre for my wife so that she can manage her e-books from every computer in the house.

Where to create the library

Myself, I use Calibre on a Linux machine which runs 24/7 (my package-build server in fact). I run a XFCE graphical desktop session inside a VNC server and that allows me to work in a desktop environment that’s always there for me. I use NoVNC to access this desktop using a web browser and that is perfect for corporate envronments which put a firewall up for everything except HTTPS traffic. Perhaps I’ll write another article sometime, explaining how to set that up.

What matters is that the Calibre library is stored on a machine with Internet access, and that this computer is running a web server like Apache. In Slackware, Apache httpd is the default webserver program.
I made this web server accessible from the Internet by configuring my ISP’s Internet router to forward ports 80 (http) and 443 (https) to the internal IP address of my Slackware machine.
For the sake of this article, let’s assume that two separate Calibre libraries exist on this computer, mine is located in /data/Calibre/EricLibrary and my wife’s books are stored in /data/Calibre/WifeLibrary . In Calibre itself, you can easily switch between libraries so that me and my wife are both able to maintain a separate collection of books. Our book tastes have no overlap…

How to configure the web server

I want both libraries to be accessible online.
I do not want to use Calibre’s own content server but instead use COPS. COPS is a collection of PHP scripts, and it does not require the Calibre program to function. It just needs access to the physical directory containing your Calibre library and it understands the Calibre SQLite database format.
If you want to get creative, you can install COPS on an Internet server – e.g. if you do not have a webserver at home. In that case, use a cloud storage service like Dropbox to keep your library in sync between your computer at home and that remote server running Apache.

My example setup is a Slackware computer at home with Apache enabled:

# chmod +x /etc/rc.d/rc.httpd
# /etc/rc.d/rc.httpd start

Apache uses the concept of a DocumentRoot, which is a directory accessible by the httpd server. Everything stored below that DirectoryRoot will be accessible via the URL of the webserver. Never store files below the DocumentRoot that you do not want to share!
I downloaded and extracted the COPS zip file directly into the Apache DocumentRoot directory (the default in Slackware is configured in the file ‘/etc/httpd/httpd.conf’ to be “/srv/httpd/htdocs/” but you can change that default location of course):

# cd /tmp
# links https://github.com/seblucas/cops/releases/download/1.1.3/cops-1.1.3.zip
# cd /srv/httpd/htdocs/
# unzip /tmp/cops-1.1.3.zip
# ln -s cops-1.1.3 mybooks
# cd mybooks
# cat <<EOT > config_local.php
$config = array();
$config['calibre_directory'] = array ("Eric" => "/data/Calibre/EricLibrary/", "Wife => "/data/Calibre/WifeLibrary/");
$config['cops_title_default'] = "Aliens Library";
$config['cops_use_url_rewriting'] = "1";
$config['cops_recentbooks_limit'] = '100';
$config['cops_update_epub-metadata'] = "1";
$config['cops_books_filter'] = array ("Books" => "!News");
EOT

The lines from the “cat << EOT” until the “EOT” on its own line is called a “here document“. You can copy/paste these lines into a terminal and it will create the file “config_local.php” with the content as shown between the “EOT” lines.
This is a configuration which allows access to two separate libraries. If you access the “recently added” section of a library it will show the latest 100 books instead of the default 20 books. It does some URL re-writing to generate cleaner URLs and it will not show any News sources (in Calibre, you can add various paid-for and free newspaper subscriptions and those will then be dpwnloaded daily, but I do not want to see those online).
Compare this configuration of mine to the ‘config_local.php.example’ file in the COPS directory. The above is not all you can configure, although it is sufficient. All configurable parameters are documented in ‘config_default.php’ which also defines their default values.

You’ll have noticed that I created a symlink to the extracted cops files, which allows me to use an easy to remember URL to access my books. Suppose my apache server is accessible as http://foo.net/ – then my COPS installation will be accessible at http://foo.net/mybooks/ .

That’s all!

Under the above ‘mybooks’ URL you will now find a COPS installation with two Calibre libraries with separate names “Eric” and “Wife”. Pick a nice template and theme, and try out the ebook-reader which is part of COPS (you  can read EPUBs in a web browser, no E-reader required).

Accessing COPS through the OPDS protocol

You want to configure your E-reader to access the library. An E-reader which contains a webbrowser is easy, just open http://foo.net/mybooks/ and click a book to download it.
Other E-readers, like FBReader for Android, are able to connect to an OPDS (Open Publication Distribution System) catalog. The COPS program exposes your library as a OPDS catalog if you just add ‘feed.php’ to the URL.
I.e. enter http://foo.net/mybooks/feed.php into the Network Library menu of FBReader and you’ll get instant access to “Alien’s Library” where you can browse Authors, Series, Categories, Recent Additions and read book descriptions, and then download the books you want to read.
If you want to always start with a list of recent library additions, you  can add ‘?page=10’ at the end of the URL so that it becomes http://foo.net/mybooks/feed.php?page=10

Hiding the cops files from the Apache DocumentRoot

Some people feel a bit anxious having these cops files accessible in their DocumentRoot – suppose someone gains access to them trough other means. You can use Apache’s “Alias” directive to install COPS in e.g. /usr/local instead. In that case, add the following lines to your /etc/httpd/httpd.conf or whatever file holds your website definition:

    <Directory "/usr/local/cops-1.1.3/">
        AllowOverride All
        Options +ExecCGI +FollowSymLinks
        Require all granted
    </Directory>
    Alias /mybooks/ /usr/local/cops-1.1.3/

You should check the validity of your httpd configuration before restarting the webserver:

# apachectl configtest
# /etc/rc.d/rc.httpd restart

And the URL to access your library will remain the same, i.e. http://foo.net/mybooks/feed.php?page=10 , only in this case your actual DocumentRoot directory will be empty.

Adding some sense of security

After following the above instructions, you now have an e-book library online whose access is not restricted in any way. If some search engine passes by it will neatly catalog all your books for other people to find. Oops!

You’ll need a basic access restriction at least. Apache offers a ‘Basic Authentication’ setup which will prompt anyone who tries to access your library for a valid account and password.
To achieve this, let’s first create a password file containing the account/password combinations for the people you want to grant access. For the sake of this example, I will grant myself and my wife access by creating account/password combinations for us in a file which we will then use in  our Apache configuration.
The first ‘htpasswd’ command below has an additional ‘-c’ parameter to create the file “/etc/httpd/passwords/htaccess.opds”:

# mkdir -p /etc/httpd/passwords/
# htpasswd -b -c /etc/httpd/passwords/htaccess.opds eric ericspassword
# htpasswd -b /etc/httpd/passwords/htaccess.opds wife wifespassword

The file will then have these contents, you see that the passwords are now MD5 encrypted:

eric:$apr1$OtKDA27W$l2ac4DAhGCG53igy6jT5A/
wife:$apr1$Zql/HEUC$wrNckoe57YPC0u2w8mL/M0

Read “man htpasswd” to find out more about this command and its parameters.

Next you need to change the Apache <Directory></Directory> block which I provided above. It will become like this:

    <Directory "/usr/local/cops-1.1.3/">
        AllowOverride All
        Options +ExecCGI +FollowSymLinks
        AuthBasicAuthoritative off
        AuthUserFile /etc/httpd/passwords/htaccess.opds
        AuthType Basic
        AuthName "OPDS Server"
        Require valid-user
        # Require all granted
    </Directory>
    Alias /mybooks/ /usr/local/cops-1.1.3/

Once you made these changes, validate the configuration and restart the webserver:

# apachectl configtest
# /etc/rc.d/rc.httpd restart

Now you will be greeted by an authentication request, next time you access your library. Only those users whose username/password combinations are stored in “/etc/httpd/passwords/htaccess.opds” will be able to get access.

Using encrypted HTTP

You should realize that these passwords will still be transmitted in cleartext if your webserver is not using HTTPS. It is possible for people to sniff the network connection and find your credentials.

I think however that instructions about enabling HTTPS for your Apache belongs in another blog post. Let me know in the comments section below if you have a need for such an article.
Also, let me know if parts of the above instructions are too cryptic and I will update the text where needed.

Good luck! Eric

Chromium 78 for Slackware

This week, Google released the first 78 version in the “stable” channel of their Chromium sources – the basis of Chrome, Opera, Vivaldi and even the Edge browsers, and of course the Chromium open-source browser itself. The release notes contain a fairly long list of security issues (CVE’s) which were taken care of.

I built packages for you today, so that you can enjoy the latest&greatest Chromium browser on Slackware 14.2 or -current.

 

What’s new in Chromium 78?

  • Tab hover cards. If you have a multitude of browser tabs open, it becomes difficult to recognize which tab has what page open. From now on, if you move your mouse over a tab you will see a small ‘hover card’ showing the title and the hostname of the page you have open in there.
  • Dark mode. You can now force ‘dark mode’ on every web site, whether the web site supports it or not. The web site code is not changed at all, and Chromium will perform a smart color inversion. You can choose between several algorithms. This is an experimental feature still, so you will have to enable it via chrome://flags like so:
    chrome://flags/#enable-force-dark
  • Chrome Password Safety tool which was available as an extension since February of this year has now been folded into the core of the browser. This feature will inform you of weak, leaked or re-used passwords in your list of saved passwords. Later on, Google is going to add functionality that will warn you when you try to use a password which is leaked online – even if you do not save your passwords in the browser.
    Still an experimental feature in this version of Chromium, you will have to enable it first via chrome://flags:

    chrome://flags/#password-leak-detection
  • A new extended menu which appears if you click “customize” in the lower right corner of the ‘new tab‘ page. Decorate the ‘new tab’ with your own background image or a different theme. This is still an experimental functionality so you have to enable it explicitly via chrome://flags :
    chrome://flags/#ntp-customization-menu-v2
    chrome://flags/#chrome-colors
  • Just missed the deadline for Chrome 78:
    DNS-over-HTTPS (DoH): Google has started a field test of its newly developed technology to tunnel your DNS queries through regular HTTPs requests. This security feature will be invaluable to those of you who do not want to risk 3rd parties to sniff your DNS requests for instance on a public Wi-Fi network. It will also prevent potential DNS spoofing attacks.
    This  Google blog article about DoH explains the caveats of using their implementation and the difference with the Mozilla Firefox implementation of DoH. Firefox enables DoH by ecapsulating your DNS requests in HTTPs and sending those to a CloudFlare server, while Chrome honours your existing DNS configuration (like paternal controls and safe browsing). The Chrome browser will check if your DNS provider is among a list of DoH-compatible providers, and swiches to your DNS provider’s equivalent DoH service. If the DNS provider isn’t in the list, Chrome will keep using regular DNS requests. Therefore, you’ll have to actively check whether this feature is going to work for you.
    As said, that same blog page mentions that this feature did not make Chrome 78 at the last moment.
    Also good to know is that the field trial is only going to be enabled for a small percentage of Chrome users (and not on Linux or iOS at all) – once it gets enabled. Not sure if this is going to be available to all of us Linux Chromium users any time soon.

Enjoy the new browser release!

Eric

Calibre 4.2.0 for Slackware with no external dependencies

One of the programs I use a lot on all my computers is Calibre, the E-book library management system. My wife and I both have Kobo e-readers, and on my Android phone I use FBReader to read my books on the road whenever I have some free time.

Having Calibre on a computer still requires a USB cable to transfer e-books from the computer to your ereader/phone, but networked alternatives exist. Calibre comes with a content server which can make your e-book library accessible online (on your LAN or on the Internet). Earlier versions of the Calibre content server were too resource-intensive and therefore I have chosen another solution for online access to my books. That’s COPS. which is short for “Calibre OPDS PHP Server“. OPDS (Open Publication Distribution System) Is the protocol through which E-readers can access online libraries. COPS allows me to download new books to read from my Calibre library over the wireless network to both my Kobo e-reader and to FBReader on my phone. No more cables needed!

FBReader on Android

FBReader accesses e-book library via COPS

Calibre is of course more than a library manager and a content server – the software comes bundled with its own e-book reader, a format converter, and an e-book editor!
Calibre is written in Python. For its graphical interface it heavily uses PyQt5 which in turn is based on Qt5 libraries.
I have been offering calibre packages in my repository for over eight years, starting with the 0.7.20 release as far as I could see (then still Qt4 based). This roughly coincided with my wife buying her first E-reader. The program has evolved a lot over the years and is much better than the proprietary library management software that ships with the major E-reader hardware.

Kovid Goyal is the primary developer, and he released a new major version of Calibre a few weeks ago. The new 4.x series delivers a completely re-written reader, a new content server with basically the same management and editing capabilities as the calibre desktop program, and a stark increase in amount and version numbers of the dependent software. For instance, Calibre 4 now depends on features in Qt 5.13.0 and PyQt 5.13.0. Several new pieces of sofware are listed in the dependencies list now, which were not required for Calibre 3.

The challenge was to create a solid Slackware package for Calibre 4. I know, you can simply download pre-built binaries for a generic Linux platform, and SlackBuilds.org even offers a build script to package these binaries for you, but it is much more fun, and very educational, to compile all of it yourself. In addition you’ll get binaries which are native to your Slackware distro instead of having to resort to binaries that were compiled on Ubuntu or Debian and do unpeakable things to your system when you’re not looking.

Luckily I have taken a week off from work, so I had time to spend on a rewrite of calibre.SlackBuild.

I also decided to do away with external dependencies. Until now, you would have to install podofo and unrar in order to fully use Calibre’s functionality. WIth my new calibre-4 package all dependencies are bundled inside. This includes Python 2.7.17 and Qt 5.13.1 as well as podofo and unrar libraries. This bundling makes it possible to build a fully functional Calibre on Slackware 14.2 (I had to add a newer version of the hunspell spell-checker because Slackware 14.2 has a version that is too old).

You can still compile a calibre package without all these internal libraries. For instance if you already have Qt 5.13.1 installed you can reduce the size of the package significantly by recompiling it. The calibre.SlackBuild will find your Qt5 libraries and won’t compile an internal version then. Same for Python 2.7. But I would recommend building the package always with the python interpreter and the slew of python modules included. It does not take that much time and you’ll be independent of updates in Slackware. Also, I do not offer packages for all those required Python modules anyway.

Here’s a couple of example command lines in case you would want to recompile. If you want create a package without any external dependency:

# BUILD_QT=YES BUILD_PYTHON=YES BUILD_MTP=YES  ./calibre.SlackBuild

In case you already have Qt 5.13.0 or newer installed and want to shrink the size of the package:

# BUILD_PYTHON=YES ./calibre.SlackBuild

Note:
On Slackware 14.2 you will have to install meson, python3 and python3-setuptools from my repository or else the compilation will fail.  Slackware-current contains all of them already.

Note:
If you have issues with Calibre 4 and think you can convince me to re-add a Calibre 3 package to my repository, let me know in the comments section below.

Note:
If you use XFCE or some other desktop environment which does not support StatusNotifier (and only supports the old X11 based XEmbed specification like the systray), then Calibre will not be able to display its system tray icon. You will have to install ‘xfce4-statusnotifier-plugin’ and its dependency ‘libdbusmenu-gtk’. Both are available as packages in my repository. After installing, right-click on the XFCE status bar, select ‘Panel > Add new items’ and add ‘Status Notifier Plugin’.

Get the new ‘calibre-4.2.0‘ package from my repository (or any mirror) and enjoy your e-book library!

If you want to know how to properly setup COPS and serve your e-book library on the internet (with or without authentication) let me know and I will devote an article to the topic. Perhaps in more generic terms, I should address the topic of reverse proxying.

Eric

KDE Plasma 5 – Slackware October release

I had already finished compiling KDE-5_19.10 and was waiting for the Plasma 5.17 public release announcement, when Pat upgraded libdvdread in slackware-current. That could mean trouble because of the dreaded ‘Shared library .so-version bump‘ message.
But he added the older libdvdread.so.4 library to aaa_elflibs so that the k3b program in Plasma5 does not break, and hopefully it remains in there until after I recompile k3b (which ultimately happens for the Plasma5 November release).

Unfortunately the earlier update of the ‘icu4c’ package broke some other stuff in Plasma5 as well. Be sure to install my ‘icu4c-compat‘ package, which contains the libraries from several older icu4c packages. Read my older article on ‘shared library .so version bumps‘ if you have not already done so, to understand the causes for this breakage.

The packages for KDE-5_19.10 are available for download from my ‘ktown‘ repository. As always, these packages are meant to be installed on a full installation of Slackware-current which has had its KDE4 removed first. These packages will not work on Slackware 14.2.

What’s new in the October 2019 release

This month’s KDE Plasma5 for Slackware contains the KDE Frameworks 5.63.0, Plasma 5.17.0 and Applications 19.08.2. All this on top of Qt 5.13.1.

Deps:
The ‘cracklib’ package got a version bump, and the latest ‘phonon’ and ‘phonon-vlc’ releases have been packaged.
The telepathy dependencies have been removed completely. Indeed, the feedback on my question in the README for last month’s ‘ktown’ release made clear that no one uses KDE Telepathy. For me it never worked anyway, so this month we say good-bye to KDE Telepathy and its dependencies.
Note that ‘qt5’ and ‘qt5-webkit’ should really be recompiled to fix the icu4c broken dependency, but I do not have the time right now, and the icu4c-compat package will take care of this anyway. Soon, though.

Frameworks:
Frameworks 5.63.0 is a regular update release. See: https://www.kde.org/announcements/kde-frameworks-5.63.0.php, but there is something worth mentioning still: the packages ‘kcalcore’ and ‘kcontacts’ which were part of KDE Applications and which you would find in the kde/kdepim section of my ‘ktown’ repository, have moved to the KDE Frameworks. As part of this move, ‘kcalcore’ was also renamed to ‘kcalendarcore’.

Plasma:
Plasma 5.17.0 is the start of a new release cycle of the Desktop part of KDE. See https://www.kde.org/announcements/plasma-5.17.0.php. Some take-aways from the release notes: the Plasma startup script (/usr/bin/startkde) which was traditionally a bash script has been replaced with a C++ program which is faster than the interpreted shell script code, and also starts the various services in parallel. The devs claim that Plasma5 desktop starts up a lot faster as a result. Do you feel the same?
Chrome/Chromium should blend in more with the Breeze theme and GTK applications should have the KDE color scheme applied. There’s more to read, just follow the above link.

Plasma-extra;
I updated ‘latte-dock’ which is my default application launcher here on the laptop for a couple of months now.
Note that ‘sddm-qt5’ should really be recompiled against the new icu4c in slackware-current, but like with qt5, my ‘icu4c-compat’ package will fix the breakage for now. This one is on my TODO list for next week.

Applications;
Applications 19.08.2 is a stability and bug-fix update for the 19.08 cycle. For more information, see https://www.kde.org/announcements/announce-applications-19.08.2.php and you may still want to visit the original release notes for 19.08.0 as well.

Applications-extra:
I upgraded ‘digikam’, ‘libktorrent’, ‘ktorrent’, ‘alkimia’, ‘kmymoney’, ‘kpmcore’, ‘krita’, ‘okteta’, and the development suite ‘kdevelop’, ‘kdev-php’ and and ‘kdev-python’ to their latest releases.

Telepathy:
KDE Telepathy is no longer part of my ‘ktown’ distribution of KDE Plasma5.

Where to get it

Download the KDE-5_19.10 from the usual location at https://slackware.nl/alien-kde/current/latest/ . Check out the README file in the root of the repository for detailed installation or upgrade instructions.

Development of Plasma5 is tracked in git: https://git.slackware.nl/ktown/ .
A new Plasma5 Live ISO has been uploaded and you will find it at https://slackware.nl/slackware-live/latest/ (rsync://slackware.nl/mirrors/slackware-live/latest/)

Have fun! Eric

LibreOffice 6.2.7 packages available for Slackware 14.2

There was a recent update in my repository of LibreOffice packages, but that libreoffice-6.3.2 was just for slackware-current.

There’s a recent release in the LibreOffice 6.2 stable series as well (ok… five weeks ago, not that recent…), and so I decided to use my build box’s free weekend to come up with packages for LibreOffice 6.2.7.
This release has a security improvement over previous versions, in that it will popup a warning to the user if a document tries to run an embedded script (similar to existing warning mechanism for embedded macros).

As you may know, the Document Foundation advises the 6.2.x series for use in production environments while the 6.3.x series is targeted at technology enthousiasts. Precisely why I have 6.3.x in the repository for -current and 6.2.x will be available for users of our stable Slackware 14.2.

Note: I am no longer including support for KDE4. The “libreoffice-kde-integration” package is no longer available for the 6.2.x releases in my repository and you should “removepkg” the older version if you have that installed. The KDE4 support in LibreOffice 6 has been broken for a while and your Office applications will run great on KDE4 without that “KDE integration”. The LibreOffice UI will be based on GTK3 widgets instead and KDE4’s theming engine will make that its User Interface blends in properly.
For the libreoffice-6.3 series and onwards, I will again build ‘libreoffice-kde-integration’ sub-packages but then targeting Qt5 and KDE5. That works really well.

Enjoy! Eric

« Older posts Newer posts »

© 2025 Alien Pastures

Theme by Anders NorenUp ↑