xXPhenom22Xx
xXPhenom22Xx

Reputation: 1275

SVN update-commit Hook help needed

We have a Linux based web server (Media Temple) where we host several domains via their DV hosting solution. I have successfully created the SVN repository for one of our projects but now I would like it to sync the live web folder on committ. Both the repo and the site files are on the same server... Paths are as follows:

The SVN Repo is here: /home/svn/repositories/<site name>

The Live Site files are here: /var/www/vhosts/<domain>/httpdocs/<subdomain>

I can connect to the repo without problem. The live site works as well. Now I just need to get them to sync.

I have created the following update file as per guide and correctly updated the POST-COMMIT.tmpl but still no dice. http://www.frenssen.be/content/using-subversion-automatically-update-live-website

Here is the code in my update program:

#include <stddef.h>
#include <stdlib.h>
#include <unistd.h>
int main(void)
{
    execl("/usr/bin/svn", "svn", "update",
        "/var/www/vhosts/<domain>/httpdocs/<subdomain>",
        (const char *) NULL);
    return(EXIT_FAILURE);
}

And I called the program in the POST-COMMIT.tmpl file with the following:

#!/bin/sh
/home/svn/repositories/autoupdate/autoupdate

Any ideas what I am missing? There has to be an easier way to get the files to sync?

Upvotes: 0

Views: 1207

Answers (3)

Lazy Badger
Lazy Badger

Reputation: 97282

  1. WC inside web-tree is always bad idea
  2. When you imported site to repo, it will not convert site automagically to WC
  3. If you still want ignore my p.1, you must 1 time perform svn co (to emptied previously??? TBT) site location in order to get WC in it
  4. More correct way for post-commit hook (from my POV) is remove all old data from site and svn export HEAD to site-path

Upvotes: 0

A.H.
A.H.

Reputation: 66263

No actually an answer (yet) but you could adapt and execute these commands on your server to gather some information about your setup:

REPO=/home/svn/repositories/XYZ
WORK=/var/www/vhosts/FOO/httpdocs/BAR

set -x

ls -ld $REPO $REPO/hooks $REPO/hooks/post-commit* $REPO/db/revs
head -2 $REPO/hooks/post-commit | hexdump -C
svnlook youngest $REPO

ls -ld $WORK $WORK/.svn $WORK/.svn/entries
svn info $WORK

Please attach the output to your question.

Edit The output has been pasted unformatted into a series of comments. Here is the relavant part:

svn info $WORK 
+ svn info /var/www/vhosts/unionjobtracker.com/httpdocs/pdc30/ 
svn: '/var/www/vhosts/unionjobtracker.com/httpdocs/pdc30' is not a working copy 

ls -ld $WORK $WORK/.svn $WORK/.svn/entries 
+ ls --color=tty -ld /var/www/vhosts/unionjobtracker.com/httpdocs/pdc30/ /var/www/vhosts/unionjobtracker.com/httpdocs/pdc30//.svn /var/www/vhosts/unionjobtracker.com/httpdocs/pdc30//.svn/entries

ls: /var/www/vhosts/unionjobtracker.com/httpdocs/pdc30//.svn: No such file or directory 
ls: /var/www/vhosts/unionjobtracker.com/httpdocs/pdc30//.svn/entries: No such file or directory 
drwxrwxrwx 8 root root 4096 Oct 19 13:15 /var/www/vhosts/unionjobtracker.com/httpdocs/pdc30/

That means, that $WORK is not a SVN-working copy. The link in your question explains the required steps in the section "Step 1: check out the repository to the web root"

Upvotes: 0

derobert
derobert

Reputation: 51147

You need to rename post-commit.tmpl to post-commit—that is, remove the .tmpl suffix. See “Implementing Repository Hooks” from Version Control with Subversion. (The .tmpl files are named as such to show they're examples, templates upon which to build your own scripts.)

Also, the guide you referenced suggests changing ownership of the hook to apache. They actually mean whichever user owner your repository (which is apparently apache for the guide writer).

Upvotes: 2

Related Questions