Automating fixDAVsvn ¬
2009-11-17
I published my fixDAVsvn script seven months (and one day) ago to automate the process of fixing apache configuration files that have been manually modified to serve up Subversion repositories (per Nayan Hajratwala’s instructions) when they’re overwritten by Server Admin. This has made managing my apache install considerably easier, but upon rolling it out on a colleague’s server this afternoon I realized it was only ever a half solution. Sure, I had saved myself considerable time just by running fixDAVsvn, but others aren’t necessarily going to want to and there’s really no need. Time to add the second half.
So, how does one automate the process of running a command on a particular file whenever it’s modified? With launchd, of course! launchd drives some admins nuts, but I find it to be quite a boon and this happens to be exactly one of the cases it was designed for. So, I whipped up /Library/LaunchDaemons/com.makkintosshu.fixDAVsvn.plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN http://www.apple.com/DTDs/PropertyList-1.0.dtd >
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.makkintosshu.fixDAVsvn</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/fixDAVsvn</string>
<string>/etc/apache2/sites/0001_any_80_svn.domain.tld.conf</string>
</array>
<key>WatchPaths</key>
<array>
<string>/etc/apache2/sites/0001_any_80_svn.domain.tld.conf</string>
</array>
</dict>
</plist>
The full path to the config file to run fixDAVsvn on needs to exist in both the ProgramArguments & WatchPaths arrays in com.makkintosshu.fixDAVsvn.plist. That said, you can add as many config files to watch and fix as you like.
So, the complete solution1 is to install fixDAVsvn and com.makkintosshu.fixDAVsvn.plist, then edit the latter to watch & fix your modified apache configuration files. I’ll likely package this all up with a script to build com.makkintosshu.fixDAVsvn.plist’s list of files automatically, but it may be another seven months.
1 This solution has been tested on both Mac OS X 10.5 (Leopard) Server and Mac OS X 10.6 (Snow Leopard) Server.

