Thursday, September 20, 2007

SVN tips

Ok here are some more tips in addition to the earlier ones. Sometimes, you want to create a copy of an existing directory to another one before making significant changes. I know that's why we have SVN in the first place, to revert to last known working copy, but at times (especially when it involves looks) it can be quite tiresome. However, SVN will not add the copied directory as it considers it already under version control. Hmm..a tough one. Actually, its pretty easy. Here's how I did it :-
  • cd /path/to/project/copied directory
  • find ./ -name ".svn" | xargs rm -fr
Now the directory is no longer under version control. You can run "cd /path/to/project/;svn add * --force" to add the copied folder to the version control. Thats all folks :D

Wednesday, September 12, 2007

Safeguard your streams

If you wish to secure a connection from 1 service to another, what would you use?
a.) Why would I want to do that?
b.) Set up VPN.
c.) SSH tunneling.
d.) Stunnel.

a.) There is no such thing as being too paranoid.
b.) Ever heard the phrase "using a nuke to kill an ant"?
c.) Same as above by replace nuke with high explosive.
d.) BINGO!!

Stunnel is an application which wraps your normal connection over SSL/TLS to make sure no one can eavesdrop on your connection. This is particularly useful when you wish to secure your mail (SMTP, POP3) or securing your SVN server (heh, its what I am using it for:P). Its main benefits is that its extremely easy to set up (within 5 minutes) and it
only establishes a connection when needed, and not
maintain its secure tunnel perpetually, which eats up
your bandwidth unnecessarily.

This is my instruction on setting it up (for Ubuntu) on the server (svn as an example). Feel free to change the location and/or configuration to suit your needs.

  • sudo apt-get install stunnel
  • mkdir -p /home/shinning/secure_services/pid
  • mkdir -p /home/shinning/secure_services/service
  • cd /home/shinning/secure_services/
  • [create server cert] - openssl req -new -days 365 -nodes -out newreq.pem -keyout stunnel.pem
  • vi /home/shinning/secure_services/service/
  • stunnel -P /home/shinning/secure -p /home/shinning/secure_services/stunnel.pem -d 4000 -r localhost:3690

And that it. Your SVN server is now running securely on top of SSL/TLS making it hard for anyone to sniff your traffic. You can also make your client authenticate itself against your server if you want to by following this guide. There are also tonnes of other examples here. Happy securing ;)

Monday, September 10, 2007

Fortune, meet planning

"Good fortune is what happens when opportunity meets with planning - Thomas Alva Edison"

The above saying is SOO true. How many times have we had the oppurtunity to do big things, but we failed because we didn't have a proper plan. And NO, I'm not talking about a bid to take over the world. Unless that's your plan of course, then I ain't gonna stop you. Perhaps the following tool can help you list out the things you have to do and set a timeline for it :P

The tool I'm talking about is called Planner which exists for both Linux and Windows. Think MS Project, but cross platform. Having never used MS Project before, its hard for me to say what are its limitations. However, its been really useful to me so far and far easier to use than some other project management software i.e. TaskJuggler.

For those using Linux, you can probably find it in your repository. In Ubuntu "sudo apt-get install planner" is sufficient to download and install this nifty software. Happy planning :D

Some screenshots are below for your viewing pleasure
Task allocation

Resource allocation and usage

GANTT chart

Saturday, September 08, 2007

My first version control

Ok, now we've got our versioning control server up and running. Now what? Now we start using it. I'll list the more basic command/uses here using the CLI. If you like, you can check out some other documentation on SVN.

  • Creating a repository
    • Log in to svn_srv
    • svnadmin create --fs-type fsfs /path/to/svn/repository_name
    • chgrp -R svn /path/to/svn/repository_name
    • cdmod -R 770 /path/to/svn/repository_name
    • cd /path/to/svn/repository_name/conf
    • Edit the svnserve.confauthz and passwd file appropriately if you wish to disallow anonymous access and only allow authorized users to access your repository (recommended).

  • Importing an existing project to the above created repository
    • svn import /path/of/existing/project/folder svn://svn_srv/repository_name --username user_in_authz_file -m "Log message"

  • Downloading a fresh copy of the repository
    • svn checkout svn://svn_srv/repository_name /destination --username user_in_authz_file

  • Sync-ing a local copy with the changes in the repository
    • svn update --username user_in_authz_file  [-r revision_we_want_to_sync_with]

  • Show exact changes in files which have changed from repository and your local copy
    • svn diff --username user_in_authz_file [-r revision_we_want_to_compare_with]

  • Show things which have changed on your local copy and the repository
    • svn status -u

  • Adding new files to be added to the version control (recursively adds files and folders)
    • svn add * --force

  • Merging changes from two sources to the current copy
    • svn merge --username user_in_authz_file --no-auth-cache -r revision_to_merge_to:revision_to_merge_from /path/to/changed/copy
    • svn merge --username user_in_authz_file --no-auth-cache  URL@revision_1 URL@revision_2 /working/copy/path

  • Deleting a file from the local copy or in the repository
    • svn delete svn://svn_srv/repository_name/file
    • svn delete path/to/file
  • Undo all local changes (does not work with removed directories)
    • svn revert --recursive
    • svn revert path/to/file
  • Commit your changes to the repository
    • svn commit

By no means is the above a complete list of options or things you can do with SVN. Read the documentation and try it out for yourself to see the power of this tool.Or, if all this looks too complicated, we could use a GUI for it. Some of the are listed below :-

So many versions, so much confusion

How many times have you worked on a project or document only to
accidentally delete a critical file, made a modification and wished you
had the original copy, or simply keep track of all the changes to your
project. The most common way is to create an exact copy before doing any changes. It works, but it takes up unnecessary space and unless you keep a good listing of your changes, you'll be scratching your head wondering where to begin.

Obviously there is a solution for this, otherwise it'd be pointless to
write this entry now wouldn't it:P The solution is pretty simple
actually. Install a version control software :D And yes it IS easy to
set up as it sounds. It's the using it that's slightly confusing, but
I'll address it in a later post. For those who don't know what version
control is, check out this Wikipedia article.

This HOW-TO is based on thw howto from this site. I DO NOT take credit for this work and I'd like to express my appreciation to all the people who made possible. I'll be using the client/server version for this guide. It is also possible to set one up to be accessible via web but I'm not going to touch it here. The HOW-TO for that is already available.

On Ubuntu (regardless of version), follow the following step-by-step to
get your version control software up and running :-
  1. Install the necessary software needed.

    • sudo apt-get install subversion subversion-tools xinetd

  2. Create a user and group that will be have read/write access to the repository directory.

    • sudo adduser --system --no-create-home --home /var/svn --group --disabled-login svn

  3. Create the directory where the repositories will reside (your projects/documents)

    • mkdir /opt/svn
    • chown -R svn:svn /opt/svn

  4. Lets make the software listen on its own connection port.

    1. vi /etc/xinetd.conf/svnserve

      • add the following to the above file

      • service svn
        port = 3690
        socket_type = stream
        protocol = tcp
        wait = no
        user = svn
        server = /usr/bin/svnserve
        server_args = -i -r /var/svn
      • quit and save the contents. This makes our svn server listen to TCP connections on port 3690.

    2. vi /etc/services

      • Check if there is an entry similar to "svn 3690/tcp subversion # Subversion protocol". If you changed the port to something else, make the changes appropriately.
      • If it doesn't exist, add it in, otherwise just quit.
      • Note : If the above entry doesn't exist in /etc/services, the svn will not start.

    3. /etc/init.d/xinetd restart

    4. Check if our svn server is now listening on our
      designated port.

      • netstat -tuanp | grep 3690

And that's all there is to it. Now you have your very own version
control software ready to use. My next post will cover creating and
managing your repository.

I'm also thinking on how to make this also useful for incremental backups. Until then, stay sharp and lets support Open/Free software :D.

Rise of the Star

Gosh. It's been more than a YEAR since I last blogged. Damn where DOES the time go. Been caught up in some projects and getting distracted here and there ;) Well lets see how long I can keep this blogging thing again before I get lazy :P

P/S : I will also try to answer any questions or comments posted from now on. I apologize for the comments which have not been answered earlier.