Set up a free CalDAV server

Apple’s Darwin Calendar Server (DCS) is a free, open-source CalDAV server that works with iCal. It’s not the only one, but it’s a good choice—as long as you don’t mind a bit of command-line tinkering. For these instructions, you’ll need a Mac running Leopard that also has Xcode Tools installed (you can find it on your Leopard Install DVD in the Optional Installs folder). On that Mac, open Terminal (Applications/Utilities) and enter this command, followed by Return (note that this should all appear on one line):

svn checkout http://svn.calendarserver.org/repository/calendarserver/CalendarServer/trunk /CalendarServer

This command downloads the DCS source code and puts it in a folder called CalendarServer at the top level of your hard disk. Next, to download additional required libraries and do an initial setup, enter the following two commands, pressing Return after each one:

cd /CalendarServer
./run –s

To set up a preliminary preference file and delete some files that may cause some confusion later on, enter:

cp ./conf/caldavd-test.plist ./conf/caldavd-dev.plist
rm ./conf/caldavd.plist 
rm ./conf/caldavd-test.plist
rm ./conf/accounts.xml

Now you have to set up user account information. DCS can use any of several methods to look up user details, including Open Directory (the method Leopard Server defaults to, and the one that offers the most flexibility). For a small group, however, the easiest setup to get up and running is one that stores all account information in a simple XML text file. That’s the method I describe here. Located in the conf folder, this file is called accounts-test.xml. You can edit it in Terminal (using, say, nano or vi) or open it in Apple’s TextEdit, Bare Bones Software’s $125 BBEdit, or another text editor.

For basic operation, you can leave all the existing text in place, but make sure that somewhere between the opening <accounts realm="Test Realm"> tag (you can change that name to whatever you want, by the way) and the closing </accounts> tag, you include the following information for each user who will access your calendars; substitute the user’s name, e-mail address, and so on:

<user>
    <uid>shortname</uid>
    <guid>shortname</guid>
    <password>password</password>
    <name>Full Name</name>
    <cuaddr>mailto:user@domain.com</cuaddr>
</user>

In addition, because true delegation of one user’s calendar to another is currently impossible without the use of Open Directory, you may choose to include another entry for a basic, low-security shared calendar for the group. Enter a password that all group members will use (note that the e-mail address doesn’t have to be a real one):

<user>
    <uid>shared</uid>
    <guid>shared</guid>
    <password>password</password>
    <name>Shared Calendar</name>
    <cuaddr>mailto:shared@domain.com</cuaddr>
</user>

You must also make a few small edits to the file caldavd-test.plist. First, locate the key ServerHostName. Immediately after that is a line that says <string>localhost</string>. Replace localhost with your computer’s actual IP address (which you can discover in the Network pane of System Preferences). If you have to choose between its public IP address and the private address used on your local network, pick the local address. Next, decide whether you want to have normal, unencrypted access to your calendars or use SSL to encrypt calendar traffic. (Either way amounts to about the same effort; SSL gives you more security but may be unnecessary on a local network.) Depending on your decision, you’ll make one of two changes. Look for this portion of the file:

<!-- HTTP port [0 = disable HTTP] -->
<key>HTTPPort</key>
<integer>8008</integer>

<!-- SSL port [0 = disable HTTPS] -->
<key>SSLPort</key>
<integer>8443</integer>

For an unencrypted connection, replace the 8443 in the second section with a 0. For an encrypted connection, replace the 8008 in the first section with a 0. (In some network configurations, leaving both options enabled at the same time produces unpredictable results, so you’ll achieve the best results if you choose one or the other.)

Finally, locate the key BindAddresses. Below that is a line that says <string>127.0.0.1</string>. Leave that in place, but immediately beneath it, add a second line that’s identical except that it contains your computer’s real IP address—again, use its private address if you have a choice. Save the caldavd-test.plist file.

Now, to run the server, enter the following in Terminal: ./run -d

You should now be able to connect to it following the instructions in “Corral Your Calendars”. When adding any user’s account in iCal, after entering the Description, Username, and Password, click on the triangle next to Server Options and enter the server’s IP address and port into the Server URL field, in the following format: http://192.168.0.10:8008 (substituting the server’s actual IP address); use https and 8443 instead of http and 8008 if you’ve set up DCS to use SSL.

To make the server run automatically every time you restart your computer, you must follow several additional steps:

1. Open the file run (in the top level of the CalendarServer folder) in a text editor. You must make changes to this file in two places to enable it to run automatically at startup (thanks to Toby Rush for discovering this issue and describing the fix on his blog). First, find these lines:

case "${USER}" in
  wsanchez)
    proto="svn+ssh";
    ;;
  )
    proto="svn";
    ;;
esac;>

and replace them with just this one:

proto="svn";

Then, find these lines:

case "${USER}" in
  cyrusdaboo)
    base="svn+ssh://cdaboo@svn.osafoundation.org/svn";
    ;;
  )
    base="http://svn.osafoundation.org";
    ;;
esac;>

and replace them with this one:

base="http://svn.osafoundation.org";

2. Launch Peter Borg’s free Lingon utility. Click on New, select Users Daemons, and click on Create. Then enter com.apple.calendarserver into the Name field; enter /CalendarServer/run -d into the What field; select Run It When It Is Loaded By the System (at Startup or Login); and click on Save.

3. Log out and log back in. The Calendar Server process should run automatically in the background. These steps provide only a very basic CalDAV setup. To add locations or resources (both of which do support delegation, even without Open Directory), or to further customize your setup, you’ll need more information than we can supply here. A good place to start is the calendarserver-users mailing list, or the searchable list archive.

recommended for you

Corral group calendars

Read more »

Subscribe to the Apple @ Work Newsletter

Comments