Posted By

uptimejeff on 11/04/10


Tagged

server ical


Versions (?)

iCal Server Merge-ics


 / Published in: Bash
 

Combines .ics files from OS X Server iCal Server into a single merged ics which can then be subscribed to. I set this up specifically so I could display ical server calendars inside of Zap Calendar on a joomla site. This script could be called from cron.

  1. #!/bin/sh
  2.  
  3. ### VARIABLES ###
  4.  
  5. # Path to user's ical server directory this is where a folder exists for each calendar.
  6. calpath="/Volumes/Data/iCal/calendars/__uids__/AC/03/AC0339D9-5D40-41CD-B1C8-4A62333C53FD"
  7.  
  8. # Where to store combined ics files
  9. # typically this is a a folder in your web server path.
  10. calout="/Volumes/Data/Web/mydomain/ics"
  11.  
  12.  
  13. ### Do not edit below this line ###
  14. cals=`ls $calpath | grep -v dropbox | grep -v inbox`
  15.  
  16. TEMP="/tmp/temp.ics"
  17.  
  18. for cal in $cals; do
  19.  
  20. echo "BEGIN:VCALENDAR
  21. PRODID:-//merge//example.com//
  22. VERSION:2.0
  23. X-WR-CALNAME:example.com" > $TEMP
  24.  
  25. awk '/BEGIN:VEVENT/,/END:VEVENT/' $calpath/$cal/*.ics >> $TEMP
  26.  
  27. echo "END:VCALENDAR" >> $TEMP
  28.  
  29. tr -d '\r' < $TEMP > $calout/$cal.ics
  30.  
  31. done
  32.  
  33. exit 0

Report this snippet  

You need to login to post a comment.