Friday, October 5, 2007

Publishing calendars in Linux

Many corporate environments already deploy a published calendar system with Exchange. From the end-user perspective, it's simple to use. From an IT perspective, it's oftentimes riddled with problems, forcing the department to baby-sit the Exchange server on a daily (or nightly) basis. As for the smaller business, it's just not cost-effective.

What if I told you there is a cost-effective, reliable way to publish calendars using the Linux platform? Well, there is, and I'm going to show you how to do it using Firefox, an Apache module, and the Firefox Lightning plug-in. Here's how it works.

What's a published calendar?

A published calendar is a calendar that can be viewed from a remote location. This enables, for example, on administrator to create and manage a calendar for, say, an entire company and everyone within the company would have access to viewing said calendar. This makes life easy when scheduling such things as company-wide meetings and events.

Getting and installing the components
Here's what you need:

  1. Apache Web server
  2. mod_dav
  3. Thunderbird
  4. Lightning

The environment I'm installing on is Fedora Core 6. For Fedora 7, the installment will be virtually the same. For other distributions, the installation will need to be modified based on the type of distributions and the architecture of the hardware.

Typically, with an installation of Linux, the Apache Web server will be installed. If, however, you have installed a desktop-only installation, you will need to install Apache as well. This can be done with the yum installation tool with the yum install httpd command (run as root). Once this is installed, you will have the /var/www/html directory, which you will use later.

The next pieces of the puzzle will be installed in different ways. Let's get mod_dav installed now. The easiest way to install mod_dav is with rpm. Get the rpm file from rpmfind.net and run the command (as root, from the directory the file downloaded into): rpm -ivh mod_dav-XXX.rpm where XXX is the release number and architecture.

Now let's get Thunderbird and Lightning installed. These are very straightforward. Download the files Thunderbird and Lightning. You must next move Thunderbird to a different directory. Where exactly this is depends on how you want to manage it. If you have all users on a system to be able to run Thunderbird, move Thunderbird to the /opt directory. If this is a system where only a single user works from, you can install Thunderbird into the users ~/ directory. To be safe, we'll install into /opt.

Once the Thunderbird file is in /opt, issue the command tar xvzf thunderbird-XXX.tgz where XXX is the release number. Now Thunderbird can be started by issuing the /opt/thunderbird/thunderbird command.

The final installation step will require you to get through the initial set up of Thunderbird. So go ahead and run through setting up your mail account. Once that is complete go to the Tools menu and select Extensions. A new window will open (Figure A) that allows you to install new extensions. Unlike Firefox, installing extensions in Thunderbird is a bit different. In Thunderbird, save the extension to your hard drive and press the Install button (from the Thunderbird extensions window), navigate to the saved file (the file extension will be .xpi), and press Open; once the count-down completes, press Install.

Figure A
You can press the Get More Extensions link to open up a new browser window and find more Thunderbird extensions.
Now you're installed, but you're not quite done.

Configuring Apache's mod_dav

Open /etc/httpd/conf/httpd.conf (as root) in your favorite text editor. Scroll to the bottom of the file and add the following lines:

Open /etc/httpd/conf/httpd.conf (as root) in your favorite text editor. Scroll to the bottom of the file and add the following lines:

Order Allow,Deny

Allow from all

Dav On

AuthType Basic

AuthName DAV

AuthUserFile user.passwd

require user admin

# Location of the WebDAV lock database.

DAVLockDB /var/lib/dav/lockdb

DAV On

AuthType Basic

AuthName "WebDAV Restricted"

AuthUserFile /etc/httpd/passwd/passwords

require user webdav

Now you need to create the webdav user and a password for that user. Do so with the command:

htpasswd -c /etc/httpd/passwd/passwords webdav

You will be prompted to enter a password for the user (twice). This password will be the password users will need to know in order to gain access to the published calendar.

The final steps will be to create the location that will house the calendar files. I created /var/www/html/webdav with the command (run as root):

mkdir /var/www/html/webdav

Make sure the directory was world-readable and writable with the command:

chmod -R 777 /var/www/html/webdav

Now start (or restart) the Apache server. I tend to start (or restart) Apache with the command:

/etc/rc.d/init.dhttpd start

or, in case of a restart:

/etc/rc.d/init.d/httpd restart



Setting up your calendar

Now it's time to fire up Thunderbird with the new Lightning extension. When you start up Thunderbird, the Lightning extension will exist in the bottom left corner, as shown in Figure B. It's clean and takes up little space, yet it remains very usable.
Figure B
Click on any date in the small calendar to open up the full-sized version in the large right-side window


There are three tabs in the extension. Press the Calendars tab to create a new calendar. Press the New button, as shown in Figure C, to initiate the creation process.
Figure C


From this tab, you can create a new calendar, edit existing calendars, or delete existing calendars


The next step is to choose the location of the calendar. Since we are creating a published calendar, we're going to select On The Network. Press Next to continue. The next step is to choose the type of calendar (I will use iCal) and fill out the location. The location of this calendar will be hosted on the machine I am working on, so http://localhost/webdav/ will work. For those working on other machines, replace localhost with the IP address of the machine serving the calendar. Press Next. Now give the calendar a nickname and select a color to represent the calendar. Press Next.

You will now be asked for the username (webdav) and the password you used when you created the user above. Enter those and press OK. Now the new calendar should show up in the calendar listing of the extension, as shown in Figure D.
Figure D

A very simple way to test the calendar's availability is to open up a browser on a remote machine and enter the address in the URL bar (in my case, http://192.168.1.21/webdav/company_calendar.ics). You will be prompted for the username and password. What will appear (if using an ICS file) will be a long file (depending upon the amount of entries in the calendar) with text similar to this:

BEGIN:VCALENDAR

VERSION:2.0


PRODID:-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN

BEGIN:VTIMEZONE

TZID:/mozilla.org/20070129_1/America/New_York


X-LIC-LOCATION:America/New_York


BEGIN:DAYLIGHT


TZOFFSETFROM:-0500


TZOFFSETTO:-0400


TZNAME:EDT


DTSTART:19700308T020000


RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3


END:DAYLIGHT


BEGIN:STANDARD

TZOFFSETFROM:-0400

TZOFFSETTO:-0500

TZNAME:EST

DTSTART:19701101T020000

RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11

END:STANDARD


END:VTIMEZONE

BEGIN:VEVENT

CREATED:20070714T234024Z

LAST-MODIFIED:20070715T021150Z

DTSTAMP:20070715T021150Z

UID:37845adf-0a08-4958-a3d4-a8aed34ba687


Connecting to the calendar
Naturally, this step will differ completely depending on the type of application you're using to connect to the remote calendar. Since we created the calendar with the Thunderbird extension, I am going to show you how to subscribe to the calendar with KDE's Kontact. This is a very simple procedure.

Open up Kontact and press on the Calendar button. Now press the Add button to begin the process of adding the remote calendar. The first step is to select the type of calendar you will be creating. Choose Calendar In Remote File, as seen in Figure E

Figure E
Kontact allows you to create any number of calendar types.

Once you select the proper type, press OK to move on. Now you are going to have to fill in the details of the remote calendar. Figure F shows just what you need.

Figure F
Here you can choose settings such as Read Only and auto-reload/save settings.

Remember, you will need to enter the entire address (including file name) for the remote calendar. In this case, the address is http://192.168.1.21/webdav/company_calendar.ics. You also have to select a location for the remote file to be saved to. For simplicity's sake, I chose the local users home directory. This can be placed anywhere, so long as the user has read/write privileges. Press OK and you're done. You will be asked for the password of the file and the calendar -- named Company Calendar as per our Kontact settings --will appear in the Kontact calendar window.

Obviously, the steps for subscribing to this calendar will vary depending upon what application you use to view it remotely.

Final thoughts

As you can see, deploying a published calendar with Linux is a fast and easy process. On top of being simple, it's reliable. And of course, it's highly configurable. This setup can be tweaked in numerous ways to suit your company's needs. If you want a reliable, cost-effective, publishable calendar system, this method is it.

1 comments:

Anonymous said...

You should also take a good look at Kolab - http://www.kolab.org/
I think it is an even more comprehensive groupware solution.