wissel.net

Usability - Productivity - Business - The web - Singapore & Twins

This article is part of a mini series. Read them all:

Adventures in Calendars

Running a CalDAV server on Ubuntu (2020 edition)


When playing with calDAV it makes sense to have a reference implementation to refer to. The GOLD standard ist Apple's CalendarServer with its lovely Open Source Repository.

Getting it to work on Linux (Ubuntu in my case), isn't for the faint of heart. Here is what you need to do.

File system preparation

Calendar server needs extended attributes. The default Ext4 file system does support them out of the box, but you want to check first (you might have a different file system after all):

Check if file system supports extended attributes

Check using this command:

touch test.txt
setfattr -n user.test -v "hello" test.txt
getfattr test.txt

Expected output: user.test

If the command setfattr is not available, install with sudo install attr

Enable extended atttributes if required

Important if the previous command worked, skip this step. Don't mess with fstab! Make a backup copy if required and have your emergency boot stick ready. A messed up fstab will prevent your machine from booting!

Edit /etc/fstab. In the 4th colum of the file system add user_xattr. There might be values like noatime or defaults. Add user_xattr separated by a comma. Reboot.

Install calendar server

Execute sudo apt install calendarserver postgresql.

The server wants a postgresql database, so you need to be sure to have that installed too. Apple loves Python, so there ill be quite some phython packages installed, as well as a new user caldavd Since this is a system user, its home directory is /var/spool/caldav

Configure the calendar server

Execute sudo nano /etc/caldavd/caldavd.plist (if you don't have nano install it or use vi)

  • Set the server host name
  • Optional: Switch on SSL and look for the SSL / TLS section for keys

Edit /etc/default/calendarserver uncomment start_calendar_server=yes

Configure the database

There used to be a script calendarserver_bootstrap_database which is missing from the current installation, so we do it the hard way:

sudo -u postgres createuser caldavd --no-createdb --no-createrole --no-superuser
sudo -u postgres createdb --owner=caldavd caldav
sudo -u caldavd psql -f /usr/lib/python2.7/dist-packages/txdav/common/datastore/sql_schema/current.sql caldav

Check with sudo service calendarserver status and then start with sudo service calendarserver start - it also will restart on reboot

Obsolete information (found in other instructions)

When poking around (see also the links below), one comes across a lot of frustration, fine geeki-speak and quite some outdated information.

Some of the things you don't need to try (or do for that matter):

  • copy files from /usr/share/doc/calendarserver/examples
  • check for file sudoer.plist (gone, not needed anymore)
  • run calendarserver_bootstrap_database - it's gone (even if the manpage still exists)
  • look for calendarserver_manage_postgres - gone
  • launch calendar with /etc/init.d/calendarserver start
  • create extra users
  • mess with permissions
  • install extra packages (YMMV here!)

The result

You will have a calendar server listening on localhost:8008 with 2 users:

  • admin / admin
  • test / test

DO NOT USE SUCH A SYSTEM IN PRODUCTION

Next steps

  • Configure HTTPS
  • Use a different user directory
  • backup your stuff
  • Install the Test suite and run it

Check the documentation for details!

Sources

As usual: YMMV


Posted by on 01 February 2020 | Comments (5) | categories: calDAV WebDevelopment

Comments

  1. posted by Ted Dively on Friday 02 October 2020 AD:

    Thank you for writing this. I'm experimenting with Ubuntu Server 20.04 LTS on a repurposed late 2009 Xserve, and it seems to run very well. However, the calendarserver package no longer seems to exist in the repositories. Any idea how I can get it? Should I just go to "git clone -b CalendarServer-9.2 https://github.com/apple/ccs-calendarserver.git", and use that source?


  2. posted by Bobber on Monday 29 March 2021 AD:

    I'm trying to get calenderserver up and running on Debian. I used your sql commands to set up postgres. When I start it up I get this in the error log with a python trace callback:
    pg8000.core.ProgrammingError: (u'ERROR', u'ERROR', u'42501', u'permission denied for table calendarserver', u'aclchk.c', u'3488', u'aclcheck_error', u'', u'')

    The table is there. What could be causing the problem?

    Thanks!


  3. posted by Jordan on Monday 02 August 2021 AD:

    I'm having the exact same issue as Bobber, using Debian 10 with calendarserver on one system and postgres on another. Any help greatly appreciated :)


  4. posted by Jordan on Monday 02 August 2021 AD:

    I'm having same issue as Bobber, running pg and calendarserver on different VMs, Debian 10 on both.


  5. posted by Jordan on Tuesday 03 August 2021 AD:

    I had same issue as Bobber. It turns out I didn't run 'current.sql' as the caldav user and that was what was causing those errors. I re-ran correctly and everything works! HTH