[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Updating a live website with a post-commit hook script

From: Bob Proulx <bob_at_proulx.com>
Date: 2006-06-29 08:54:43 CEST

Graham Anderson wrote:
> 1) Is there an example script and tutorial on how to update a live
> web site with a post-commit hook script ?

I don't know if official examples exist but the implementation is
really only a few lines.

> 2) Does this comply with a 'best practices' use for subversion ? At
> this point, I am a bit too green to evaluate if this is ok.

Yes. This is a best practice. It is recommended in the FAQ as you
noted in your message.

  http://subversion.tigris.org/faq.html#website-auto-update

Let's assume a subversion repository at /srv/svn/www and a web
document root at /srv/www. You could have a post-commit hook at
/srv/svn/www/hooks/post-commit with this content:

  #!/bin/sh
  cd /srv/www || exit 1
  svn update --quiet
  exit 0

A very simple process. Change directory to the live web working copy
and update it.

This process will run as the web process uid. On my machine that
means the www-data user. On other machines it will be different. The
live working copy needs to be owned by the www-data user or at least
be writable by it so that the web server uid can update it.

Of course you don't need to use the https:// protocol to update. You
could use the svn+ssh:// protocol. But if you are updating a web page
then we can assume that you have a web server and so have https://
available. This avoids a permission problem.

If you use svn+ssh:// then the post-commit is run as the committing
uid which will be different for everyone. For a web server document
root keeping it writable by everyone is probably not what you want to
do. This is where the little C program wrapper described in the FAQ
becomes useful. Set up a set-uid program to switch to a pseudo user
to update the web document root. Make it writable only by that pseudo
user.

Hope that helps!
Bob

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Thu Jun 29 08:55:55 2006

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.