The Network People Solutions for Hosting Providers | ||
How I created my own .mac replacement2004.08.16 - Published by Matt Simerson My .mac subscription is 60 days from renewal so I have to ask myself, "how useful is .mac to me? Is it worth another $100?" Is .mac worth it to me? Many of the reasons I don't find .mac useful are the same reasons I encourage others to use .mac. One has to keep in mind that I'm not an "average" computer user. My needs are different and Apple wouldn't make any money trying to sell a .mac like service to guys like me. This is not an "I hate .mac" site but rather an explanation of the motivation and methods I used to provide myself with comparable services that are more usable to me. I publish it so that others may benefit from what I have learned. This is published to help others, but don't expect free support from the author. Support requests that arrive without monetary compensation for my time will almost certainly be ignored. Instead, try using the support forums and maybe someone will help you out. My use of .mac services
Project Goals:
Is it possible: First I had to determine if I could even achieve comparable results using resources I already possess. My first endeavor was scrub the net looking for folks that have already done similar things. Apparently, SpyMac is where .mac refugees who don't have their own servers go. While it doesn't appear to be impossible, it certainly doesn't seem like well charted territory. Plan of Attack
Set up webdav: The first order of business is to get webdav installed and configured. I run Apache 2 on FreeBSD, so I already had mod_dav installed. It was just a simple matter of configuring it. I did so by first creating two directories for use by WebDav. The /home/idisk directory is the one to be used by webdav clients, the /var/run one is used internally by Apache. mkdir /home/idisk /var/run/webdav chmod 755 /var/run/webdav chown www:www /home/idisk /var/run/webdav Note that my Apache server runs as the user www. If you run Apache as some other user (nobody is common), then make sure to alter the chown command to suit. DavLockDB /var/run/webdav/DavLock <VirtualHost *:80> ServerName idisk.cadillac.net DocumentRoot "/home/idisk" </VirtualHost> <Directory "/home/idisk"> Dav on AuthType Digest AuthName iTools AuthDigestDomain "/" AuthDigestFile /usr/local/www/WebDavUsers <LimitExcept GET OPTIONS> require valid-user </LimitExcept> Order allow,deny Allow from All </Directory> The next task is creating the password digest file that Apache will use for authentication. htdigest -c /usr/local/www/WebDavUsers iTools mattsimerson Finally, I created a DNS record for idisk.cadillac.net and restarted Apache. I was able to use the Finder's "Connect To Server" menu item and connected directly to http://idisk.cadillac.net. Very nifty, now I have something resembling my own iDisk. Since my web server is also on my home LAN, I'm connected to it via full-duplex 100 Base-T so it's way faster than using Apple's iDisk. Apple's iDisk is painfully slow, despite my extremely fast T3 internet connection. Getting WebDav to work was the easy part. Publish iCal calendars on webdav: My wife and I enjoy being able to share each others calendars. Until now, we had shared them via .mac. To get them published via webdav was trivial. I first created a directory on the server to store them: It was then a simple matter to select each calendar in iCal and choose "change location". A dialog box will pop up and you simply fill in the new details.mkdir /home/idisk.cadillac.net/Calendars After updating all our calendars, I also modified them so that now they auto-publish after each change. When using .mac, I had them update every hour, as updating would take quite a number of seconds to complete. Now the publishing of changes is so fast that it's transparent. From there it was a trivial exercise to get PHP iCalendar to publish our calendars via a web server. I simply configured it to view the calendars in /home/idisk/Calendars. iCal .mac integration: The next step was to get iCal to publish to my server with .mac settings. I created a test calendar and tried publishing it to .mac. It failed because the Sites/.calendars folder didn't exist. After I created that directory, iCal happily exported my test calendar to my new iDisk. This is obviously much better as calendar space is no longer "shared." Now we can both publish a calendar named "Work". This change does complicate web access via iCal. Now PHP iCalendar needs to know your username in order to know which calendar to display. To solve this problem I did two things. The first was requiring HTTP authentication to view calendars. This is arguably something that should be done anyway. I did so by updating the following block of code in httpd.conf: <Directory "/usr/local/www/phpicalendar"> Options Indexes ExecCGI AllowOverride Limit Order deny,allow deny from all AuthType Digest AuthName iTools AuthDigestDomain "/" AuthDigestFile /usr/local/www/WebDavUsers require valid-user satisfy any </Directory> Now when I visit my iCal site, I have to authenticate using my webdav credentials. The last little tidbit was getting PHP iCalendar to know where to find my calendar files. I added the following little code snippet to config.inc.php, immediately after the $calendar_path declaration: if (isset($_SERVER['REMOTE_USER'])) { $calendar_path = "/home/idisk/".$_SERVER['REMOTE_USER']."/Sites/.calendars"; } If I haven't passed HTTP authentication credentials, I get the normal icalendar behavior. If I authenticate, my published calendars are displayed. The only remaining anomoly is that the publish URL that iCal shows is on the ical.mac.com server. Obviously, I'd need to point ical.mac.com to my server, or just re-write the URL to point to my server. The latter requires less effort. Patch mod_dav for quota support: mod_dav quota UPDATE! Andreas Amann wrote to point me at a better mod_dav patch by William Carrel with better quota support. The URL is here and I've mirrored it here. I've tested the patch and it reports back your free disk space on the server. However, when I enabled quotas on my FreeBSD server, it doesn't honor them. This is not quite ideal but better than the previous patch though so it's linked here. Emulate www.mac.com: The next step was to convince my mac that my new webdav server was Apple's iDisk server. This was not quite so easy but I had Otto's site as a guide which helped tremendously. The first thing I did was the normal server stuff so that my FreeBSD server would act like Apple's iDisk server. This involved the following steps:
Get Backup.app working: Upon running Backup.app, a check of my Apache log files revealed that it was checking the URL "https://www.mac.com/WebObjects/Info.woa/wa/Query/accountInfo". As before, we install a script there to capture the POST data and see what it's looking for. We end up with this in the temp file: SERVER_SOFTWARE = Apache/2.0.50 (FreeBSD) SERVER_NAME = www.mac.com GATEWAY_INTERFACE = CGI/1.1 SERVER_PROTOCOL = HTTP/1.1 SERVER_PORT = 443 REQUEST_METHOD = POST HTTP_ACCEPT = image/gif, image/jpeg, image/pjpeg, */* PATH_INFO = PATH_TRANSLATED = SCRIPT_NAME = /WebObjects/Info.woa/wa/Query/accountInfo QUERY_STRING = REMOTE_HOST = REMOTE_ADDR = 10.0.1.218 REMOTE_USER = AUTH_TYPE = CONTENT_TYPE = text/xml CONTENT_LENGTH = 165 { body = {keys = (iToolsBackupActivated, trialAccountDaysLeft); }; function = accountInfo; header = {password = *******; username = mattsimerson; }; } Once again, save the contents within the {} brackets into a temp file "foo" and post them to Apple's URL.. I did so with the following Lynx command: So, now we need to set up the accountInfo script to return that value when Backup queries it. I did so by editing the following file:{ payload = { iToolsBackupActivated = Y; }; statusCode = success; } The contents of that file should be something like what follows:vi /home/www.mac.com/WebObjects/Info.woa/wa/Query/accountInfo After making this change, the first time you run Backup, it'll check your server, see that you have Backup activated and let you back up your Mac(s) to your local iDisk server. I don't know how often it performs this check but after having done so, I haven't seen it check again (unless I delete the Backup prefs file).#!/bin/sh echo Content-type: text/plain echo cat << EOT { payload = { iToolsBackupActivated = Y; trialAccountDaysLeft = -1; }; statusCode = success; } EOT I now have iDisk and Backup access on all three of my computers (dual G5, PowerBook, and wifes iMac) without purchasing multiple .mac accounts. Excellent, this is better than .mac! Configure a Proxy Redirecting www.mac.com to my server creates a new problem in that now I can't visit www.mac.com from my LAN. Since I still do have a .mac account, I wish to retain that ability. To do so, I adjusted my Apache config file a little more by adding some proxy directives.
The one last loose end is adding iSync support so that I can use my own server to sync Address Book, iCal, and Safari bookmarks between my systems. Jeremy Baker has headed down that road so I expect to spend some time tinkering with that in the future. NOTES Platform Independent: This solution is not even remotely dependent on FreeBSD. I could have just as easily implemented this solution on my Linux or Mac OS X systems. I chose my FreeBSD server because it's already the gateway between my LAN and the internet. Because it's dual homed, I can access it locally on the LAN as well as remotely with my PowerBook without playing silly network tricks (like VPN or SSL tunnels). iPhoto Homepage publishing: It's broken. I don't know why yet. I intend to figure out why at some point but don't hold your breath because it's not very important to me. I use Gallery with the iPhotoToGallery plugin and BetterHTMLExport with a template I customized. iSync still works with .mac synchronization disabled but I lose the ability to sync between computers. That's a major loss. Dominic also mentioned using disk images for users DAV space. Combine this with his script for fetching disk usage and you've got working per-user disk space reporting.
.mac, iCal, iDisk, iSync, and a few other things listed here are probably registered trademarks of Apple Computer.
Last modified on 4/25/05. |
|