Bits and thoughts

#!/bin/bash is not rude


Calendar and contacts server

Written by ⓘⓓⓔⓝⓣⓛⓤⓓ - -

This post dating from 2012 is still relevant in September 2014 !I'm still on my trajectory to lower my Google dependency . As for now I have already hosted my own emails and I have tried to reduce as much as possible any incoming spam . Calendars and Contacts are the next step.


Calendars and Contacts are respectively based upon two standards   
Both are derived from WebDAV protocol. There are many products that implement these standards. I chose Baïkal for some reasons :   
  • It looked easy to setup
  • It brought what I needed and not the full range of groupware solution
  • It added a lightweight administration layer to manage users and their Calendars or Address Books.

Baïkal setup

Setting up the web application

I downloaded Baikal and un-tarred it in its own directory : /var/www/baikal. and I made sure that it was owned by default Apache user www-data
cd /tmp
cd /var/www
tar -xzvf /tmp/baikal-regular-0.2.3.tgz
mv baikal-regular/ baikal
chown -R www-data: baikal/
I edited .htaccess file that was alread present in /var/www/baikal/html to add "Allow from all" directive because my Apache configuration is locked by default on every directory.I  created an Apache virtual host to reach Baïkal pointing to /var/www/baikal/html accessible with https through /etc/apache2/sites-available/
<VirtualHost *:443>
        DocumentRoot /var/www/baikal/html
        <Directory "/var/www/baikal/html">
                Options None
                Options +FollowSymlinks
                AllowOverride All
        SSLEngine On
        SSLCertificateFile    /etc/ssl/certs/certificate.pem
        SSLCertificateKeyFile /etc/ssl/private/priv_key.pem
Any http access will be redirected to https through /etc/apache2/sites-available/
<VirtualHost *:80>
        <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteCond %{HTTPS} off
        RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
And then I had to enable these configurations in Apache :
It never hurts to check if Apache is happy with this configuration :
apache2ctl configtest
And then an Apache reload
service apache2 reload

Setting up MySql database

By default Baikal uses a SQLite database but it can run on MySql ... and I happen to have a MySql dabase running ...
# mysql -p
mysql> create database baikal;
mysql> grant all on baikal.* to 'baikaluser'@'localhost' identified by 'password';
mysql> \q#
mysql -u baikaluser --database=baikal -p
mysql> @/var/www/baikal/Core/Resources/Db/MySQL/db.sql
mysql> show tables;
| Tables_in_baikal |
| addressbooks     |
| calendarobjects  |
| calendars        |
| cards            |
| groupmembers     |
| locks            |
| principals       |
| users            |
I'm good to go ...

Web application setup

Open a browser and navigate to . The first step is to set up an admin user account ...

And then you need to setup the database connectivity :

Users setup

The final step is to declare users through the administration interface :

Client configuration


My desktop client is Evolution here is how I set it up, Calendar:

and Contacts :

Android 4.x

On Android I used one application for caldav and carddav :
  • DAVDroid   Open source calendar and contact synchronisation adapter available on independently managed application repository : F-droid
Independently signed certificates such as the one I use (certified by are not recognized by Android. In order for DAVDroid to be able to connect to my https Baïkal server I had to import root certificate into the phone :
  • On the phone download the root certificate
  • It should propose you to switch the settings of the phone in order to add the certificate to the user's approved container.
  • At this step you MUST have set up an unlock method for the phone (draw a schema, type a password or a PIN) ... this will be enforced by Android itself
The final setup consists in indicating the servers, the user and its password as in Evolution, using 'Accounts' in Android settings.


Migrating my Google Contacts to Baikal is as simple as a copy and paste in Evolution