====== Setting up a post-commit mail notification for a Subversion repository ======
Setting up SVN post-commits can allow you to automatically update your webroot whenever a change has happened to SVN. It is a script that runs after every commit and is pretty simple to implement:
First make sure your SVN is setup properly by following: [[accelerators:apache_svn|Setup Apache with Subversion]]
After this is done, verify everything is working properly. Note that your entire svn directory should be owned by the user that Apache is running as.
Then create a file /path/to/svn/repos/hooks/post-commit and have it look like:
#!/bin/sh
/path/to/svn/repos/hooks/update
Set it executable:
# chmod +x /path/to/svn/repos/hooks/post-commit
post-commit should be owned by the user apache is running as.
Create the /path/to/svn/repos/hooks/update.c file:
#include
#include
#include
int main(void)
{
execl("/opt/csw/bin/svn", "svn", "update", "/path/to/web/public/",
(const char *) NULL);
return(EXIT_FAILURE);
}
Compile it, set proper permissions:
# cc -o update update.c
# chmod +x update
# chmod u+s update
# chmod g+s update
They should look like:
-rwsr-sr-x 1 bsmith bsmith 7.9K Jan 10 19:06 update*
Make sure your /path/to/web/public is a working copy.
You can verify things are working by running the svn update as your regular user, in this example 'bsmith'.