Search | Sailfish OS | Running | PineTime | All Posts

Fixing Baikal not working on FreeBSD

March 27, 2023 — Nico Cartron

Baikal suddenly stopped working, here's a quick tip on how to fix this


The Problem

I'm using Baikal as CalDav/CardDAV server.

This morning when checking my calendar on my laptop, I noticed that it wouldn't sync.

I checked Baikal's web page on my dedicated server, and got greeted with:

 baikal was not able to establish a connexion to the configured MySQL database

Hum, indeed a few days before, I upgraded it.

What was weird is that it worked for a while, and then stopped working.

Investigating

Sqlite issue?

I looked at the Baikal configuration but got confused by the fact that it's mentioning a sqlite file:

database:
  sqlite_file: /path/baikal/Specific/db/db.sqlite

I looked and couldn't find that file, so I thought it got deleted by the Baikal update I did a few days before.

"Damned, I'm gonna lose a few meetings created since then".

I looked at recent backups, but there was no db.sqlite.

Then I looked again at the file, and saw a MySQL section - and remembered that indeed, I had a baikal database; I confirmed it by logging into the DB and seeing the different tables.

Diving a bit deeper

Then it struck me that Baikal uses PHP, so I should check whether I had issues with it.

I created a basic page which calls phpinfo(), but it displayed just fine.

Then I checked whether there was a PHP extension for MySQL:

# pkg search php81 |grep sql
php81-mysqli-8.1.13            The mysqli shared extension for php
php81-pdo_mysql-8.1.13         The pdo_mysql shared extension for php
php81-pdo_pgsql-8.1.13         The pdo_pgsql shared extension for php
php81-pdo_sqlite-8.1.13        The pdo_sqlite shared extension for php
php81-pear-MDB2_Driver_mysqli-1.5.0.b4 PEAR MySQL MDB2 driver
php81-pear-MDB2_Driver_pgsql-1.5.0.b4_2 PEAR pgsql MDB2 driver
php81-pgsql-8.1.13             The pgsql shared extension for php
php81-sqlite3-8.1.13           The sqlite3 shared extension for php
squirrelmail-change-sqlpass-plugin-php81-3.3_3 Allows users to change their passwords stored in a SQL database
squirrelmail-sasql-plugin-php81-3.2.0_3 Edit SpamAssassin settings stored in an SQL DB

OK - there is php81-pdo_mysql, which I confirmed was not installed (with a pkg version).

Fixing it

Alright, let's install this package!

 # pkg install php81-pdo_mysql-8.1.13
 Updating FreeBSD repository catalogue...
 FreeBSD repository is up to date.
 All repositories are up to date.
 pkg: py37-pelican has a missing dependency: py37-feedgenerator
 The following 1 package(s) will be affected (of 0 checked):

 New packages to be INSTALLED:
         php81-pdo_mysql: 8.1.13

 Number of packages to be installed: 1

 17 KiB to be downloaded.

 Proceed with this action? [y/N]: y
 [1/1] Fetching php81-pdo_mysql-8.1.13.pkg: 100%   17 KiB  17.6kB/s    00:01
 Checking integrity... done (0 conflicting)
 [1/1] Installing php81-pdo_mysql-8.1.13...
 [1/1] Extracting php81-pdo_mysql-8.1.13: 100%
 =====
 Message from php81-pdo_mysql-8.1.13:

 --
 This file has been added to automatically load the installed extension:
 /usr/local/etc/php/ext-30-pdo_mysql.ini

Then I restarted Apache, reloaded my Baikal home page, which this time worked fine!

A refresh of my calendars also worked fine, so problem fixed!

Wrap Up

Sometimes things break, and this can happen.

What I had problems understanding is: why did that happen days after my Baikal upgrade.
Then I remembered that I have a crontab restart my Apache on Sunday to reload it and have it taking into account any new Let's Encrypt TLS certificates :) (yeah I know, I should improve that).

Anyway, I'm glad this got fixed!


Tags: FreeBSD, Tips


I don't have any commenting system, but email me (nicolas at ncartron dot org) your comments!
If you like my work, you can buy me a coffee!