Saturday, June 30, 2007

Personal Settings in SVN Increases Happiness by 125%!

This may sound a little silly, but when I first started using aliases in Linux (and loving their potential utility), I was put off by the realization that once I got used to using them, I would end up being on another machine without them. This annoyance made me resistant to using them for some time. Eventually, I started using them so much, that I copied my .bashrc (and .vimrc and other such files) to all the remote servers I would need to interact with regularly.

This helped quite a bit, but it introduced another level of annoyance. Whenever I made a change, improved a command, added a new alias, I would have to add that to all the copies I had floating around. Dumb. Dumb and annoying.

So, I thought, why not set up a repo? While I use SVN regularly, I had never setup one on my own before, so it seemed like a win/win situation. In sum, the following is what I did to get it all to work.

The first thing to decide is how the repository will be accessed, either via SSH or Apache. The use of Apache is very common, and there are many tutorials on how to do it (like this one). I chose not to use Apache for 2 reasons: I did not want to have to be concerned with securing Apache on the server in question unless necessary, and secondly any computer on which I would want to access the repositories would have SSH. If you want to be able to see your repo in a browser, use Apache (or Trac).

Initial steps:
sudo apt-get install subversion # As of now on Feisty, this installs 1.4.3
sudo mkdir /home/svn/configfiles #For the repo, easy place to remember

You can replace "configfiles" with whatever you want to call the repo. For this case, it does not matter a lot, since I will be checking out the files in many various places, not all in one directory.

Now for permissions and such:
sudo addgroup subversion
sudo usermod -a -G subversion YOURUSER

And the real magic:
sudo svnadmin create /home/svn/configfiles/
sudo chown -R subversion configfiles # make sure perms are right after repo creation
sudo chmod g+rws configfiles # Ditto
sudo svn import /your/initial/files file:///home/svn/configfiles/repo -m "initial import"
sudo apt-get install xinetd

Now run
sudo vim /etc/xinetd.conf
and add:

service svn
port = 3690
socket_type = stream
protocol = tcp
wait = no
user = www-data
server = /usr/bin/svnserve
server_args = -i -r /home/svn

Now go into the conf dir in your repo and
sudo vim svnserve.conf
and edit what you like. I uncommented "anon-access = read" and "password-db = passwd".

You are done! The test: "svn co svn+ssh://SERVERWITHREPO/home/svn/configfiles". You will be prompted for as password 3 times, do not worry. If all is well, you should see "Checked out revision 1.", and the file(s) in the repo will not be in the dir where you ran the above command.

For more info, see the SVN Book. Thanks to this guide for getting me through the main steps.

[NOTE:] After some experimenting, I ended up creating the repo like this:
sudo svnadmin create /home/svn/configfiles/trunk
sudo svn import ~/.bashrc file:///home/svn/configfiles/trunk/bashrc -m "Initial import of .bashrc"

Then I checked it out via:
svn co svn+ssh://SERVERWITHREPO/home/svn/configfiles/trunk ~/DIR/TO/CHECKOUT/IN

Also, the way to delete a repo completely (as I did during testing) is simply to remove the entire dir (e.g. "sudo rm -rf /home/svn").


Post a Comment

Subscribe to Post Comments [Atom]

<< Home