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 (0) | categories: calDAV WebDevelopment

Comments

  1. No comments yet, be the first to comment