Question

I have been reading some of the other similar questions people have asked with the post-commit hook. But have not found one which is close enough to my issues that it provides an answer :(. I have an SVN repository which I am able to checkout, and when I commit I am trying to hook it so that it will automatically update a webroot folder.

Currently my post-commit script looks like this:

#!/bin/sh

#REPOS="$1"
#REV="$2"

cd /var/www/thecruisein.com_dev/ && /usr/bin/svn update --username anon --password anon

Which has the permissions of:

-rwxr--r--. 1 apache apache 122 Jan 28 10:00 post-commit

However when I try to commit my changes to a file via NetBeans I get the following error:

org.apache.subversion.javahl.ClientException: E175002: Commit failed (details follow):
E175002: Processing MERGE request response failed: Element type "http:" must be followed by either attribute specifications, ">" or "/>". (/subversion/thecruisein_dev) 
E175002: MERGE request failed on '/subversion/thecruisein_dev'

I have disabled SELinux for the time being (with no change in behaviour :( ) and the permissions for the /usr/bin/svn file are:

-rwxr-xr-x. 1 apache apache 181500 Apr 11  2013 /usr/bin/svn

When I completely remove the post-commit script things function as expected (except the webroot doesn't get updated of course). So it seems to be an issue with subversion having this post-commit script enabled.

Any help would be greatly appreciated as I'm not sure where to turn next :(

Was it helpful?

Solution

Turns out that I needed to execute a complied program in the post-commit hook.

My compiled program is "autoupdate" which has this:

#include <stddef.h>
#include <stdlib.h>
#include <unistd.h>

int main(void) {
  execl("/usr/bin/svn", "svn", "update", "/var/www/thecruisein.com_dev/", "--username", "anon", "--password", "anon",
    (const char *) NULL);
  return(EXIT_FAILURE);
}

My post-commit script looks like this:

#!/bin/sh

REPOS="$1"
REV="$2"

/var/svn/thecruisein_dev-autoupdate &>/dev/null

(&>/dev/null ---This redirects any output to prevent interference)

The file permissions of the compiled C program are such:

-rwsr-sr-x   1 apache apache 4813 Jan 28 11:40 thecruisein_dev-autoupdate

This solved the issue and allows commits to be made and automatically show up in the expected webroot folder.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top