Auto-Update SVN on Media Temple (gs)

I wanted to update SVN every 5 minutes on my Media Temple grid service (gs) account. Here is the steps I took to make that happen.
First, I created a shell script with the SVN Update (I’ll show how in a minute). I got this error:
Error validating server certificate
For some reason SVN wasn’t reading my trusted server list, so I asked (mt) about it.

Josh Kline at Media Temple pointed out the issue. I’m not sure why this isn’t documented somewhere, so I’m blogging it.
SVN looks for the config, including the trusted server list, in
$HOME/.subversion
Your cron jobs run withHOME=/home/#####, but when you ssh inHOME=/home/#####/users/.home
running svn with--config-dir /home/#####/users/.home/.subversionwill fix the problem.
That said, here are the steps to get SVN to auto update every 5 minutes. SSH in, you will have to go through the steps to enable SSH.
cd data
mkdir scripts
vi cron.sh
In your cron.sh, use the config command that Josh suggested (replacing ##### with your id)
svn update SVN_PATH --config-dir /home/#####/users/.home/.subversion
Go into the (mt) control panel under Cron Jobs and configure one to run your shell script.

There you have it, you now have svn auto updating on shared hosting.
7 comments
A cron job running every 5 minutes? Yikes!
Why not use the svn hook scripts to update on commit or another event rather than using a cron job?
royalol: 5 minutes to run a small shell script is not a big deal at all. The server can handle a few commands, especially a svn update every 5 minutes.
travi: Shared hosts do not allow you to run hook scripts last I checked. I have covered writing hook scripts before, so yes I do know about them – thanks though.
Marc: I wasn’t trying to suggest that you didn’t know about hook scripts, just curious what was preventing you from using them. I use them at Dreamhost (they take some additional configuration to get them working due to write access: http://wiki.dreamhost.com/index.php/Subversion#Automatic_Post-commit_Checkout) so I’m surprised Media Temple doesn’t allow them. Interesting though. Good solution if they are not available to you.
Hey Marc, I use the Media Temple Grid Server too, and have setup post-commit hooks. Here’s one I use to email updates:
REPOS=“$1”
REV=“$2”
REVP=$REV
REVP=$[REVP-=1]
SUBJECT=“New (Insert repo name) commit r$REV: `svn log -r HEAD file://$REPOS | tail -n +4 | head -n 1`”
LOG=“`svn log -r HEAD file://$REPOS | tail -n +5`”
DIFF=“`svn diff file://$REPOS -r$REVP:$REV`”
echo “$LOG $DIFF” | mail email1@domain.com email2@domain.com -s “$SUBJECT”
I tried to get a post-commit auto update working but ran into trouble and didn’t push too hard. Maybe with the info in your article here it can be done though.
Ah I got it to work with Post-Commit :)
REPOS=“$1”
DOMAINS=/home/#####/domains/
SVN=/usr/bin/svn
SVNCONFIGDIR=/home/#####/users/.home/.subversion
DOMAIN=${REPOS:29}
UPDATEPATH=$DOMAINS$DOMAIN/
$SVN update $UPDATEPATH —config-dir $SVNCONFIGDIR
My script assumes you have your repositories in /home/#####/data/repositories/[DomainName]
Nice job, thanks Anthony.