Everybody Staze...

Nobody leavz...

  • Home
  • About Me
    • LinkedIn
    • Lab
  • Contact
  • Links
  • Reviews
  • Sitemap
  • Weather
You are here: Home / Sys Admin / Fun with iCal Server

Fun with iCal Server

2010/03/10 By staze

We run an iCal Server at work, and the mandate has been handed down that everyone needs to be subscribed to a “Vacation Calendar” that a couple people in the building maintain (my boss, the head of Operations, and the Dean’s assistant). For the most part, this has been really easy. We just created a “Vacation” user, and subscribed people to it’s calendar on the server with iCal. However, we have a couple PC users in the building that use Outlook, and Outlook wants an ICS file to subscribe to… not a directory. It seems like iCal Server is supposed to (or at least version 1 did) give the client a combined ICS file if you just hit the directory of the user’s calendar without specifying anything else. This doesn’t appear to work though.

So, as a work around, I wrote up a very simple shell script that concatenates all the ics files for the vacation user into one ICS.

#!/bin/sh

#This users caldav directory. Something like:
#/Library/Calendar/calendars/__uids__/7E/1B/7E1B373E-8F22-469F-8BDF-5C3ECB996156/calendar
INPUT=""
TEMP="/tmp/temp.ics"
#Where you want the combined ics file to go. Should be a web hosted directory if you expect to have clients subscribe to it. Something like:
#OUTPUT="/Library/WebServer/Documents/vacation.ics"
OUTPUT=""
echo "BEGIN:VCALENDAR
PRODID:-//Vacation Merge//example.com//
VERSION:2.0
X-WR-CALNAME:Vacation Calendar" > $TEMP

cat $INPUT/*.ics | grep -v "BEGIN:VCALENDAR" | grep -v "END:VCALENDAR" >> $TEMP

echo "END:VCALENDAR" >> $TEMP

tr -d '\r' < $TEMP > $OUTPUT

The big points here are, while you can just do `cat *.ics > /some/place/merged.ics` the “BEGIN:VCALENDAR” and “END:VCALENDAR” are still in there, which end up at the start and stop of each of the events in the calendar. Calendar software will stop reading once it hits one of those “END:VCALENDAR”… so the `grep -v` just removes those, and we add an end at the very end, just as we added a begin at the start.

The last line is to add unix line endings… because for some reason, this script is producing DOS line endings. *shrugs* Probably just the beginning block that has the wrong line endings. Anyway, it works.

That pretty much does it. It’s very simple. I have it run with cron every hour.

Good luck.

Print Friendly, PDF & Email

Filed Under: Sys Admin Tagged With: .ics, iCal Server, merged, outlook, subscribe

Weather

Categories / Archives

  • Apple
  • Coding
  • Electronics
  • Energy
  • Home Ownership
  • Miscellany
  • Politics
  • Prius
  • Sys Admin
  • Travel
  • Uncategorized
  • Work
  • June 2026
  • April 2026
  • August 2025
  • April 2025
  • January 2024
  • February 2021
  • July 2020
  • January 2020
  • April 2019
  • March 2018
  • February 2018
  • June 2017

Copyright © 2026 · Staze On Genesis Framework · WordPress · Log in