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
[server] # 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.
Startup
Since i use OpenRC, to start radicale simply create the following script under /etc/init.d:
- /etc/init.d/radicale
#!/sbin/openrc-run # Copyright 1999-2021 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 description="Radicale WebDAV / WebCAL server" pidfile="/run/radicale.pid" command_background=true command="/data/daemons/radicale/.local/bin/radicale" command_args="" command_user="radicale:users" depend() { need net }
Make it executable and add the service to the default runlevel:
chmod +x /etc/init.d/radicale rc-update add radicale default
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.