A Linux tale… [updated]

My wife and I seem to share a lot of activities recently. We finally gathered a few friends around here with which we do regularily stuff like playing card games and she even got me to take Salsa dancing lessons with her. Beside that my political interests and meetings are quite regular as well, so it was just natural to think about a event planning solution which would allow us to view, add and edit events. I decided we need a calendar server!

So I started looking around for calendar server solutions. I already had a rather hacky webdav-alike setup on my Virtual Private Server (VPS) which consisted of a single ICS file, secured by a simple HTTP authentication and made writable through a PHP script, but this doesn’t seem to be the right solution for me. I wanted something better, something stable, something nice – and I apparently found it: Apple released its Darwin Calendar Server, which is the base of their commercial calendar server solution on Mac OS X Server, as Open Source under the Apache Software License 2.0 some time ago. “This will replace the old hackish setup on my VServer!”, I thought…

I logged into the server and quickly downloaded the project’s sources from the public SVN repository. The README file stated that it should apparently be enough to start the `run` script in the base directory which would take care of everything, i.e. download and install all dependencies which would be needed for the software to run. This even worked flawlessly (with only one little modification). Up to that point I was very cheerful – until I actually tried to start the server:

IOError: [Errno 95] Operation not supported: \
'/opt/calendarserver/CalendarServer/twistedcaldav/test/data'

Uh? Ah well, there was something in the README I overlooked:

WEBDAV PROPERTY STORAGE
-----------------------

For starters, twisted.web2.dav requires Bob Ippolito's xattr
library to access file system extended attributes, which are
used to store WebDAV properties.  File system extended 
attributes are available on all file systems in Mac OS X, and
on some file systems on Linux and FreeBSD.  Another 
alternative is to implement a new property store class which
does not use extended attributes. The Apache HTTP Server, for
example, uses a database to keep track of properties on files,
and this method works on many more platforms and file systems.

xattr? Hrm… I never heard of that before – but Google shed light into my darkness: As Wikipedia amongst others states, they are “[…] a file system feature that enables users to associate computer files with metadata not interpreted by the filesystem […]”, basically simple key-value pairs of arbitrary size and content. A quick grep over the config file of the currently running kernel showed me that at least support was already compiled into it:

$ cat /boot/config-2.6.11.4-20a-smp | grep XATTR
CONFIG_EXT2_FS_XATTR=y
CONFIG_EXT3_FS_XATTR=y
CONFIG_REISERFS_FS_XATTR=y
CONFIG_DEVPTS_FS_XATTR=y
CONFIG_TMPFS_XATTR=y
CONFIG_CIFS_XATTR=y

Cool! I read somewhere that in this case one would just have to add the mount option `user_xattr` to /etc/fstab and remount the filesystem in question and everything would be fine… Well, it would be fine if my /etc/fstab would actually contain an entry for `/`! Being on a virtual server started to get a little annoying.

But I didn’t capitulated, not yet. “Wasn’t there a way to create and mount a filesystem from a disk image?” I wondered. I used this technique a couple of times to mount ISO images and browse their contents back in my old Linux days. I read a bit further on this topic and found many helpful ressources on this topic. At first I needed to create an image file and format that with a filesystem:

# 128 blocks of 1MByte size
$ dd if=/dev/zero of=caldavdata.image bs=1M count=128
128+0 records in
128+0 records out
134217728 bytes (134 MB) copied, 0.506394 seconds, 265 MB/s
$ mkfs.ext3 -v caldavdata.image
mke2fs 1.36 (05-Feb-2005)
caldavdata.image is not a block special device.
Proceed anyway? (y,n) y
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
32768 inodes, 131072 blocks
6553 blocks (5.00%) reserved for the super user
First data block=1
16 block groups
8192 blocks per group, 8192 fragments per group
2048 inodes per group
Superblock backups stored on blocks: 
        8193, 24577, 40961, 57345, 73729

Writing inode tables: done                            
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 28 mounts
or 180 days, whichever comes first.
Use tune2fs -c or -i to override.

“Great! Now I only need to mount that baby!” I thought:

$ mount caldavdata.image /opt/caldavdata -t ext3 -o loop
mount: could not find any device /dev/loop#

Indeed, there was not one single block device in /dev starting with `loop` – in fact the only two block devices I found there at all were related to the virtual server’s own file system. In my naive thinking I continued: “Hey, if this block device is not existent, I’m pretty much sure that I can create it with mknod!”. Indeed, mknod can create any kind of char or block devices. This site pointed me to the correct needed major and minor numbers for such a device:

$ mknod /dev/loop0 b 7 0 # 'b' stands for block device
$ ls -lah /dev/loop0 
brw-r--r--  1 root root 7, 0 Feb  1 21:25 /dev/loop0

“Success!” I thought and tried the mount command again:

$ mount caldavdata.image /opt/caldavdata -t ext3 -o loop
mount: Could not find any loop device. Maybe this kernel does
       not know about the loop device?
       (If so, recompile or `modprobe loop'.)

“Yeah, apparently it does not know about device” and ran the proposed `modprobe loop`:

$ modprobe loop
FATAL: Module loop not found.

Hrm… could it be that loop wasn’t compiled as module? Grepping the config told me yes:

$ cat /boot/config-2.6.11.4-20a-smp | grep LOOP
CONFIG_CC_ALIGN_LOOPS=0
CONFIG_BLK_DEV_LOOP=y
CONFIG_BLK_DEV_CRYPTOLOOP=m

So, the last thing I could think of (as an ignorant Linux user) was to reboot the server and hope that it would somehow recognize the loopback file.

Of course, this did not work out.

I’m now in the sad process to get used to Google Calendar

[Update: Actually the only bad things about Google Calendar until today are

a) I don’t have full control of the server-side storage / backup

b) I can’t publish events to Google via iCal – well, at least I could not until today.

Apparently Google offers an RSS-alike API to access calendar data and somebody wrote a small Java server which “translates” between this custom RSS format and the standard ical format. It allows file-based synchronization (i.e. particularily useful for iCal which can’t just embed and write CalDAV ressources) and even contains a small web server to do the translation live and in place – how neat is that?!

You can download GCalDaemon here.]

2 thoughts on “A Linux tale… [updated]”

  1. I forget which mail client you use, but if you use Thunderbird, they have a nice calendar solution.

    http://www.mozilla.org/projects/calendar/

    They were supposed to be making calendar sharing an easy task in a future version (0.7 just came out and I haven’t had time to mess with it yet), but in 0.6, it’s possible and pretty easy.

    —Email I sent a couple months back with details—

    1. Optional, but I got the holiday files
      (http://www.mozilla.org/projects/calendar/holidays.html) for my
      country. Importing this will setup your base calendar, and you can
      skip #2.

    2. If you skipped #1, add an entry to your calendar. Anything,
      anywhere, just put in something to setup your base calendar.

    3. Look inside your Firefox / Thunderbird profile folder. Go to
      /calendar/. I forget what the default name is, but you’ll see two
      files. Upload something.ics to your FTP, rename as you like. chmod
      it to 777 so that you can write to it from the program.

    4. In Mozilla Calendar, go to File / Subscribe to remote calendar.
      Give it a name, check the “always publish” box, and setup the FTP
      path:
      ftp://yourusername:yourpassword@yourftpserver/yourcalendarfile.ics

    5. On the main screen, you’ll see two tabs on the upper left: Calendar
      and Calendars. Click Calendars, delete the default entry (unless you
      want all of your entries to be doubled).

    6. Under preferences, go to publishing.
      ftp://yourusername:yourpassword@yourftpserver/path/to/yourcalendarfile.ics

    7. Repeat as necessary on other computers that you want to share the
      calendar with, skipping 1-3 obviously.

    Now, when you open the calendar, it’ll grab all the changes from FTP
    in case someone else has edited it, and it’ll also upload the file as
    you edit it. If you’re on dialup, wait about five-ten seconds after
    opening the program / adding / editing an entry before doing anything
    so that it has time to upload.

    I wrote this run-through from memory, so if you’re having any
    problems, feel free to ask away… though I’d almost put money on this
    being correct, heh.

  2. Yeah, I know of Sunbird / Lightning (though iCal on Mac OS X is much nicer ;); I wasn’t aware that they’re able to sync ICS calendar files over ftp, but actually that is pretty much the same setup I already had (a simple ICS file laying around on my server being writable via webdav). I still do not give up the Calendar Server completly – maybe they’ll implement an alternative storage method for webdav properties in the future which makes the whole fuss above unneeded.

Comments are closed.