Radicale

Radicale is a CalDAV/CardDAV server.

CalDAV is the WebDAV extension to manage Calendars

CardDAV is the WebDAV extension to manage address books and contacts in general.

To add support for both, which will allow your phone to sync contacts and calendars with your home server, i choose to use the great, simple and effective Radicale server.

Please note that Radicale do not provide a user-interface to edit or use calendars or contacts, you need third party apps for that.

To install radicale, of course, you need it's dedicated user, so add user:

useradd -d /data/daemons/radicale -m radicale

Create data folder:

mkdir /data/cardcal
chown radicale:radicale /data/cardcal

Radicale uses pip, so as usual enable it on Gentoo for user Radicale by creating the file /data/daemons/radicale/.config/pip/pip.conf with this content:

pip.conf
[global]
break-system-packages = true
user = true

Install as user radicale:

su - radicale
pip install --upgrade radicale

Create the config file ~/.config/radicale/config:

config
# Bind all addresses
hosts = 127.0.0.1:5232

[auth]
type = http_x_remote_user
#htpasswd_filename = ~/.config/radicale/users
#htpasswd_encryption = md5

[storage]
filesystem_folder = /data/cardcal

then start it:

su - radicale
radicale

Reverse Proxy

As usual you want it protected by the Reverse Proxy, so create the radicale.conf file:

radicale.conf
location /radicale/ { 
# The trailing / is important!
    proxy_pass        http://localhost:5232/; # The / is important!
    proxy_set_header  X-Script-Name /radicale;
    proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header  Host $http_host;
    proxy_pass_header Authorization;
    proxy_set_header     X-Remote-User $remote_user; # allow automatic authentication using proxy credentials
    # to prevent timeouts importing huge calendars or contacts lists
    proxy_send_timeout 600;
    proxy_read_timeout 600;
}

add this config file to NGINX (see The Reverse Proxy concept for more details) and restart nginx.

Now go with browser to http://10.0.0.1/radicale to finish setup.

Autostart

Autostart, put this into /etc/local.d/50-radicale.start and make it executable: <file - 50-radicale.start> #!/bin/bash

start-stop-daemon -b -m -p /var/run/radicale.pid -n radicale -u radicale /data/daemons/radicale/.local/bin/radicale </code>

Sharing calendars

Radicale doesn't directly support sharing calendars (see here) but it's pretty easy to share calendars between users anyway by creating simple symlinks.

So, first of all login on Radicale web GUI with all the users you want to share the calendar with, then create in one of them the actual calendar.

At this point, you only need to link the calendar folder inside all he users:

ln -s /data/cardcal/collection-root/user1/72757af3-557c-e8e4-bdd7-c9bc5689b862   /data/cardcal/collection-root/user2/

and that's it.