So I setup a Subversion repository successfully. Well, turns out it wasn’t complete.
My client would like to access and change files via Subversion instead of what they were currently using, FTP. Moreover, they would like the files to exist in their webroot of their domain. Their project is a web project, after all.
After some research and discussion with peers, I found out how to do this. First, I had to add their directory as accessible via subversion. I used Subversion’s FAQ about in-place import to do what I needed. My exact commands were:
# svn mkdir file:///home/svn/rep/{repname}/domain.com -m "Initial create"
# cd /home/{user}
# svn checkout file:///home/svn/rep/{repname}/domain.com
# svn add *
# svn commit -m "Initial version of files"
That seemed to work great, the repository was setup! My client had access to read and write files to their repository, which is their webroot. However, the webroot doesn’t auto-update, so any changes won’t take effect unless it’s manually updated.
Reading further in the Subversion FAQ, I found a way to auto update the files on the website.
I created a “Tiny C” app with the following code
#include <stddef.h>
#include <stdlib.h>
#include <unistd.h>
int main(void)
{
execl("/usr/local/bin/svn", "svn", "update", "/home/{user}/domain.com",
(const char *) NULL);
return(EXIT_FAILURE);
}
Then compiled it
cc -o updaterepo postcommit.c
Then made updaterepo executable and gave it chmod +s, as suggested by the FAQ. Of course I made it owned by {user} as well. Then I created /home/svn/rep/{repname}/hooks/post-commit with the following content
#!/bin/sh
/home/{user}/updaterepo
I tested a commit, and it worked!