Tuesday, May 6, 2008

Family data-center: calendar sharing

Actually, the Internet file-sharing I wrote about previously has been totally uninteresting to my wife. Internet available calendars on the other hand!

When we were just two and she studied and studied for years we had few or no scheduling conflicts. When she started to work it was still manageable, we still only had each other to take into consideration. When we got our daughter the cup runneth full. The little critter was clearly the most important person, and our schedules had to be adjusted to her being among us: Kindergarten x-mas and easter breakfasts, parent-conference there, drop-offs and pickups adjusted to meetings and travel needs. This clearly needs a technological solution!

To be fair, I got this idea from my colleague Bjørn. His wife is a nurse, she works all kinds of hours on a weekly basis, he consults with a client that has all sorts of needs early and late and weekends and what not. And he runs a boy scout troop. They needed calendars long before they procreated.

Being an old fart/dinosaur I resisted this idea for a long time. Fortunately calendars proved surprisingly easy.

I use Thunderbird as IMAP(mail) client. There is a humongous plug in for Thunderbird called Lightning that gives it calendar abilities. There is also a standalone version of Lightning called Sunbird. In the most basic form these store .ics, Ical files locally on your machine. But that does not make them internet available. The next step up is storing the .ics files on your webdav server -- see, suddenly the webdav server became much more desirable! This is very easy, just give lightning a HTTP or HTTPS URL pointing to the webdav file and it will read and write directly to it.

There is a downside to this easy solution: You can only have one program/user attempting to update a calendar at a time. Your whole calendar is just one large file, and it can take several seconds to retrieve or save, and if someone tries to save the shared calendar at the same time, your're so SOL. So, some discipline is needed to use this. That includes shutting down all unused calendar clients, as my wife discovered some days ago, she lost her whole calendar due to some such mishap.

There is a fix to this, it's called caldav. Calendar over DAV i.e. over HTTP. The relationship between caldav and ics over webdav is the same as the relationship between Maildirs and mail-spool-files. The first works well even with multiple clients accessing and updating it at the same time, and the second sucks and is prone to corruption and data-loss.

If you're OK with not having a web interface to your calendar - there is a way to implement caldav without installing a whole groupware suite. After all you installed a working e-mail solution years ago, no need to redo that. The caldav implementation I chose/fount is called davical. It is implemented in PHP and uses Postgress for storage. It was a bit fiddly to install, maybe I did it wrong, maybe their docs were slightly outdated.

davical used to be called rscds, and therefore lives at http://rscds.sourceforge.net/. There are Debian .deb and Red Hat RPM files at source forge. Once you have them installed and read and followed http://wiki.davical.org/w/Installation_Stuff you can give your calendar URL as shown in http://rscds.sourceforge.net/clients.php. The first time I did this, and imported an old calendar with the help of Lightnings export/import functions, davical sat there quite stunned a while. And then it worked. It's fast to delete from, it refreshes quite fast compared to huge calendars in ICS files and so on.

Family data-center: file sharing

One of the joys of Linux is easy, well, relatively easy anyway, setup of Internet services.

Todays service is webdav, a file sharing protocol for the Internet based on HTTP. You will need a Internet connected Linux box that you can connect to somehow through the use of dynamic DNS or some such. My home based Internet server is an oooold laptop running Debian Etch (PII, 366MHz, 190MB, 10GB disk). Very easy to maintain, upgrade and install new stuff on. I will assume you use a modern Linux distribution in the following, and also assume that it's Debian.

Next you need Apache, and to enable the modules dav and dav_fs. On most Linux machines you can run these commands as root: "a2enmod dav; a2enmod dav_fs". And create the directory dav under the Apache Document Root to store files in. Often this will be /var/www/dav . It must be owned by the user Apache runs as, on debian that's the "www-data" user: "chown www-data /var/www/dav".

Now configure Apache. In /etc/apache2/conf.d create a new file called dav.conf:

Order Allow,Deny
Allow from all

Dav On

AuthType Basic
AuthName "Langfeldt.net WebDav"
AuthUserFile /etc/davpasswd
Require valid-user

This sets up access control for the directory and enables DAV in it. The password file is created by the htpasswd command as root. To create a first account called "janl" run "htpasswd -c /etc/davpasswd janl". For subsequent accounts or password changes drop the "-c" option. If you take out your web browser and direct it to http://yourserver/dav" you should be greeted by a password dialog. Your browser should then show a mostly empty directory listing. Firefox can only show webdav directories, but the KDE "konqueror" is able to also copy files into a webdav directory. In konqueror the URL is "webdav://yourserver/dav" or "webdavs://yourserver/dav" if you have SSL on the web server. You can use webdav with Gnome too of course.

Now you can store files on the webdav volume and access it from anywhere in the world, whenever. in.solit.us has a useful help page at http://in.solit.us/about/webdav .

That's all for today. I'll return with something that may give you more cred with the wife: family calendar services.