fixDAVsvn ¬
2009-03-07
Subversion, mod_dav, and mod_dav_svn are all pre-installed on Leopard Server, authentication via Open Directory is a piece of cake, and you can even mostly config & manage via Server Admin. Nayan Hajratwala has a good tutorial explaining the setup and the few lines you have to manually add to the apache config files, but there’s one problem: whenever you update any site using Server Admin, it replaces all occurrences of ‘DAV svn’ with ‘DAV Off’, completely defeating the purpose.
When I just had just a couple of Subversion repositories and wasn’t changing my apache configs very frequently it was fine to manually switch ‘DAV Off’ back to ‘DAV svn’ and restart apache, but recently I’ve exceeded my tolerance. So, this morning I whipped up the following bash script which accepts the names of config files that’ll need to be fixed, performs the substitution, and restarts apache:
#!/bin/bash
# # fixDAVsvn - Replace occurrences of 'DAV Off' in specified apache2 configs with # 'DAV svn' and restart apache. This helps do some dirty work on Mac # OS X Server when using Server Admin to modify apache configs if # you use DAV svn anywhere. # # v0.1 - 2009-03-07 - Morgan Aldridge <morgant@makkintosshu.com> # Initial development. #
date=`date "+%Y-%m-%d-%H%M"`
function usage() { printf "Usage: fixDAVsvn file [...]\n" }
if [ $# -gt 0 ]; then until [ -z "$1" ]; do src=$1 dst=$src-$date.bak rsync -a $src $dst # back up the original file cat $dst | sed 's/DAV Off/DAV svn/g' > $src # replace 'DAV Off' w/'DAV svn' shift done
/usr/sbin/apachectl restart # reload the apache configs else usage fi
I’d suggest installing it into /usr/local/bin/
.
Example usage:
sudo fixDAVsvn /etc/apache2/sites/0003_any_80_svn.domain.tld.conf
Let me know if you find this useful.
Update: I’ve since released a launchd job which automates the process of running fixDAVsvn
when the apache config files are modified (esp. by Server Admin).
fantastic! it works great for me and I will be using it often. thanks.
martin
5531 days ago
Excellent! I’m glad you found it helpful.
Morgan Aldridge
5531 days ago