Auto-Update SVN on Media Temple (gs): Media Temple, Linux

Auto-Update SVN on Media Temple (gs)

Tags: Media Temple, Linux | Written on 9/10/08

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 with HOME=/home/#####, but when you ssh in HOME=/home/#####/users/.home
running svn with --config-dir /home/#####/users/.home/.subversion will 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.

Bash:
  1. cd data
  2. mkdir scripts
  3. vi cron.sh

In your cron.sh, use the config command that Josh suggested (replacing ##### with your id)

Bash:
  1. 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.

Comments

#1. royalol on 11/10/08
A cron job running every 5 minutes? Yikes!
#2. travi on 12/10/08
Why not use the svn hook scripts to update on commit or another event rather than using a cron job?
#3. Marc Grabanski on 13/10/08
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.
#4. Matt Travi on 17/10/08
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.
#5. Anthony Ryan-Lorraine on 21/10/08
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.
#6. Anthony Ryan-Lorraine on 21/10/08
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]
#7. Marc Grabanski on 21/10/08
Nice job, thanks Anthony.

Leave a Comment