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

Re: Copying hooks automatically upon repository creation

From: Ryan Schmidt <subversion-2010d_at_ryandesign.com>
Date: Mon, 4 Oct 2010 13:42:34 -0500

On Oct 4, 2010, at 12:51, Tech Geek wrote:

> We use one repository per project. All repository lives in /var/lib/svn/.
>
> Also we use the hooks post-commit and pre-commit for every repository. Right now we have to manually copy these two hooks whenever a new repository is created.
> For example:
> cd /var/lib/svn/
> cp /path-to-my-hooks/* projectA/hooks
> cp /path-to-my-hooks/* projectB/hooks
> cp /path-to-my-hooks/* projectC/hooks
>
> Is there any way to automate this process?

As Andy said, you can write a script that creates the repository and then copies the scripts, then make sure you call that script instead of calling "svnadmin create" directly whenever you want a new repo. My version of this script creates the repository as the Apache user and symlinks in my common hooks and conf directories. I symlink instead of copying because I want all my repositories to always have the same hooks and conf files, and I want changes I make in them to be reflected in existing repositories. Here's my script:

#!/bin/bash

REPO="/path/to/subversion/repositories/$1"
USER="www"

if [ -e "$REPO" ]; then
        echo "Repository \"$1\" already exists." 1>&2
        exit 1
fi

sudo -u "$USER" svnadmin create "$REPO" || exit $?
sudo -u "$USER" rm -rf "$REPO"/{conf,hooks} || exit $?
sudo -u "$USER" ln -s ../../conf "$REPO" || exit $?
sudo -u "$USER" ln -s ../../hooks "$REPO" || exit $?
Received on 2010-10-04 20:43:16 CEST

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