Friday, March 18, 2011

unfuddle SVN setup with CPanel Shared hosting for small developer team

Hi mates,
I have been using unfuddle as a third party SVN and cPanel based shared hosting for development from more than one year. It is to mention that, cPanel shared hosting does not give you SVN access. But I believe you need a SVN setup for your small team and if you think you going to set it up without cost, then my shown setup will be knocking you the thing what you really need. The team size is really small, only 5 members. The benefits are as follows:

Advantages
1. FREE of cost
2. Both windows and Linux Users can setup this process
3. Writing Shell script allows cPanel's SVN to run accordingly to perform

Disadvantages
1. Unfuddle wont let you have users created more than 3, therefore a team more than 3 will have to share one or more accounts.
2. cPanel based shared hosting's part of monthly band will be using in this regard, but as long as it is a dev stage, it won't be a big issue, because your live application/site won't be conducting this process.

Below I am trying to state what were the steps I had to go through to accomplish such a setup.
1. Setup an SVN in the local system, I have used Tortoise SVN in windows 7 and windows XP.
2. create an account in unfuddle.com
3. write SHELL script to execute SVN
4. Setup cron in cPanel and thats it

Lets start processes
Below, I am showing steps required in points.

Create Unfuddle account
1. Go to http://unfuddle.com/accounts/plans , the unfuddle plan page and select Private FREE option. Or you could click here. Remember there is no credit info to register/signup.

2. Once created and logged in, you will now have to create a repository. To do this, click Repositories tab and put your project title, abbreviation and version type as subversion and then click Create repository.

3. Subversion URL: you will be given a SVN URL depending on the abbreviation input by you in earlier step, something like this.
http://codefightersbd.unfuddle.com/svn/codefightersbd_dissertation/


4. Login access: username and password for SVN login will be same as what you have used
during account creation in Unfuddle. So your team members will be using the same login access for working in SVN. However you can invite upto three people in free unfuddle account.

Configuring SVN
1. Download TortoiseSVN from here and setup in your system. I have setup 32-bit in windows 7
and windows XP, you may need to restart your PC but it depends, I do not know.

2. Create a folder named whatever your project name is. For example create a folder name, dissertation any where, may be in your htdocs or whatever place your working directory.

3. Right click on the created folder and select SVN Checkout... option. An window like below will appear, put repository SVN URL you have been given by unfuddle and then click ok. Login window will appear, put username and password and then click Save authentication checkbox and then click Ok and again Ok.

4. create files inside the directory and commit the work. your SVN is ready with unfuddle. Actually your team is ready to work with SVN now using unfuddle service. Just give the SVN URL, username and password to your team member and let him follow the steps for Configuring SVN, he will be able to join your team instantly.

Deploying works into DEV site
Now think your team has an web hosting in cPanel or a subdomain in cPanel. You want to deploy your team members work everyday in that domain automatically as soon as they commits their works. This is possible in just following simple steps.

1. Write SHELL Script: following will be the simplest SHELL script for this purpose.
For example you have a subdomain in your cPanel hosting named as mysubdomain, and it is located in your hosting in a directory like this. /home/devproko/public_html/mysubdomain
devproko is the hosting account name, yours will be different, so the directory will be actually, /home/Your_Hosting_Account_User_Name/public_html/mysubdomain

Open notepad and write following code and save that as checkout_unfuddle.sh
#To checkout from unfuddle repository
svn co http://codefightersbd.unfuddle.com/svn/codefightersbd_dissertation/ public_html/mysubdomain

Save it into a directory by creating it as cron_scripts, lets say it is in the following directory. /home/Your_Hosting_Account_Name/cron_scripts
Therefore the files's full location will be something like this.
/home/Your_Hosting_Account_User_Name/cron_scripts/checkout_unfuddle.sh

2. Configure cPanel CRON: login into your cPanel hosting account and click cron jobs tab. Lets say we will be updating our server in every 3 minutes. You may change the frequency but I use to use for every 2 minutes and it did not have any bad impact. For each two minutes this will execute the codes into checkout_unfuddle.sh file. Hope it makes sense. From the common settings option, put the values like following picture and then click Add new Cron Job button.
  • Set common settings selection as every 5 minutes
  • put */3 in Minute field
  • Put following code in Command field
    sh /home/YOUR_HOSTING_ACC_NAME/cron_scripts/checkout_unfuddle.sh

3. Now wait for minimum 3 minutes so that the server runs the shell script and check out files for only once from unfuddle server.

4. After three minutes are gone, you will have to modify the file checkout_unfuddle.sh as soon as possible. Open the file and remove all codes and paste following codes into that file:

#changing directory
cd /home/devproko/public_html/mysubdomain
#Running SVN Update Command
svn cleanup
svn update

and just save by overwriting the file into its previous location. Thats all. In every three minutes it will update the unfuddle server and will get all updates from the server that are committed by your team. This is a great success for me, hope yours will be :)



6 comments:

  1. Great stuff here and i learned a lot from this post, because you have described everything very briefly about this topic.Register Domain

    ReplyDelete
  2. really great offers provide by this provider and excellent features with excellent package.Register a Domain

    Website Domain Name

    ReplyDelete
  3. Well above explanation is excellent about this service provider and you have done a great job.domain registration india

    ReplyDelete
  4. I definitely enjoyed every little bit of it, I have you bookmarked to check out all the new stuff you post..This is a fantastic website and I can not recommend you guys enough.Website Hosting India

    ReplyDelete