Bits and thoughts

#!/bin/bash is not rude

caldav

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.

Standards

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
wget http://baikal.codr.fr/get/baikal-regular-0.2.3.tgz
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/baikal.lebegue.org-ssl
<VirtualHost *:443>
        ServerAlias baikal.lebegue.org
        DocumentRoot /var/www/baikal/html
        <Directory "/var/www/baikal/html">
                Options None
                Options +FollowSymlinks
                AllowOverride All
        </Directory>
        SSLEngine On
        SSLCertificateFile    /etc/ssl/certs/certificate.pem
        SSLCertificateKeyFile /etc/ssl/private/priv_key.pem
 </VirtualHost>
Any http access will be redirected to https through /etc/apache2/sites-available/baikal.lebegue.org
<VirtualHost *:80>
        ServerAlias baikal.lebegue.org
        <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteCond %{HTTPS} off
        RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
        </IfModule>
</VirtualHost>
And then I had to enable these configurations in Apache :
a2ensite baikal.lebegue.org baikal.lebegue.org-ssl
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 https://yourserver.xxx/admin/ . 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

Evolution

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 CACert.org) are not recognized by Android. In order for DAVDroid to be able to connect to my https Baïkal server I had to import CACert.org root certificate into the phone :
        
  • On the phone download the CACert.org 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.

Conclusions

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