Monday 10 September 2012

Migration from SVN to GITORIOUS and move into GITHUB


1.      svn co svn://serverip/svn/repo
2.      cd repo
3.      svn log -q | awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" <"$2">"}' | sort -u > authors-transform.txt
4.      vi authors-transform.txt
5.      svn info
6.      git svn clone svn://serverip/svn/repo --no-metadata -A authors-transform.txt --stdlayout /root/repo
7.      cd /root/repo
8.      git remote add origin git@git.abc.com:test/myrepo.git
Remove .SVN folder from GIT
find . -type d -name .svn -exec git rm -rf {} \;
To create a duplicate of a repo without forking, you need to run a special clone command against the original repo and mirror-push to the new one. This works with any git repo, not just ones hosted on GitHub.

overall workflow for migration will be as follow
1) Make Gitorious  repo read only so that nobody can push to git repo
2) Do git clone with bare -- flag from Gitorious
3) Do push --mirror to github
4) Ask developers to change remote to github (Each developer will have to do this step)
Lets do this thing!
In order to make an exact duplicate, you need to perform both a bare-clone and a mirror-push:
git clone --bare https://github.com/exampleuser/old-repo.git# Make a bare clone of the repo

cd old-repo.git
$ git push --mirror https://github.com/exampleuser/new-repo.git# Mirror-push to the new repo

cd ..
$ rm -rf old-repo.git# Remove our temporary local repo
Every Developer needs to following stepcd existing-working-copygit remote set-url origin git@github.com:/exampleuser/new_repo.git# change remote for existing clone pointing to old repo. Command above will set local clone to use new repo as remote

Cacti Configurations


Install and Configure Cacti

  1. Extract the distribution tarball.
shell> tar xzvf cacti-version.tar.gz
  1. Create the MySQL database:
shell> mysqladmin --user=root create cacti
  1. Import the default cacti database:
shell> mysql cacti < cacti.sql
  1. Optional: Create a MySQL username and password for Cacti.
5.  shell> mysql --user=root mysql
6.  mysql> GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'somepassword';
mysql> flush privileges;
  1. Edit include/config.php and specify the database type, name, host, user and password for your Cacti configuration.
8.  $database_type = "mysql";
9.  $database_default = "cacti";
10. $database_hostname = "localhost";
11. $database_username = "cactiuser";
$database_password = "cacti";
  1. Set the appropriate permissions on cacti's directories for graph/log generation. You should execute these commands from inside cacti's directory to change the permissions.
shell> chown -R cactiuser rra/ log/
(Enter a valid username for cactiuser, this user will also be used in the next step for data gathering.)
  1. Add a line to your /etc/crontab file similar to:
*/5 * * * * cactiuser php /var/www/html/cacti/poller.php > /dev/null 2>&1
Replace cactiuser with the valid user specified in the previous step.
Replace /var/www/html/cacti/ with your full Cacti path.
  1. Point your web browser to:
http://your-server/cacti/
Log in the with a username/password of admin. You will be required to change this password immediately. Make sure to fill in all of the path variables carefully and correctly on the following screen.

Samba File Shareing


1.       Install samba on your system
2.       Go to /etc/smb.conf
3.       Create a folder for sharing    “mkdir –p /var/www/html/book”
4.       Create a user which you given rights to access it   “adduser test

**
[global]
        workgroup = TEST
        netbios name = BOOKSERVER
        server string = Samba Server Version %v
        log file = /var/log/samba/log.%m
        max log size = 50
        os level = 33
        preferred master = Yes
        local master = No
        security = user 
 [book]
        comment = Book Share
        path = /var/www/html/book
        valid users = test
        writeable = yes
#       write list = test
        directory mode = 0777
        create mask = 0777
For given access to xyz user for sharing:                      smbpasswd –a xyz

Gitorious Server


Gitorious is an open source application originally developed for hosting open source projects in git repositories This guide also covers how to install the services Gitorious is dependent on,
including:
  • Web server (Apache)
  • Database server (MySQL)
  • Ruby (Enterprise Edition)

Install Required Packages

Gitorious needs a lot of software:
yum install -y git git-svn pcre pcre-devel zlib zlib-devel sendmail ;
yum -y groupinstall "Development Libraries" "Development Tools" ;  
yum install -y libssh2 libssh2-devel openssh openssh-server \  
    memcached libyaml libyaml-devel ImageMagick ImageMagick-devel  \  
    apr-devel uuid java-1.6.0-openjdk readline-devel glibc-devel \  
    openssl-devel gcc-c++ gcc-c++ zlib-devel openssl-devel readline-devel \  
    sphinx

Install Ruby and Rubygems

Gitorious runs on a variety of Rubys (>= 1.8.6). If you want to use the basic
Ruby, you can install it with:
yum install -y ruby ruby-devel rubygems
If you want to install Ruby Enterprise Edition, you have to download the source
tarball. The source tarball contains a cross-platform installer. This guide is
based on Ruby Enterprise so I recommend to use it.
wget http://rubyforge.org/frs/download.php/68719/ruby-enterprise-1.8.7-2010.01.tar.gz
tar xzvf ruby-enterprise-1.8.7-2010.01.tar.gz  
./ruby-enterprise-1.8.7-2010.01/installer

Install Required Gems

Gitorious requires a lot of gem packages.
gem update --system
gem install --no-ri --no-rdoc rails mongrel mime-types \  
    textpow chronic ruby-hmac daemons mime-types oniguruma passenger \  
    textpow chronic BlueCloth  ruby-yadis ruby-openid geoip ultrasphinx \  
    rspec rspec-rails RedCloth echoe hoe diff-lcs stompserver json mysql
Important! Latest version of rack wasn’t compatible with our testing
environment, you may need to use version 1.0.1 instead.
gem install --no-ri --no-rdoc -v 1.0.1 rack

Install and Configure MySQL

Gitorious should work with any SQL server, but it’s only tested with MySQL.
·         Install MySQL
·         yum install mysql mysql-server mysql-libs mysql-devel
·         Start the service
·         service mysqld start
·         Set a password for root user. Replace <password> with your own password.
·         mysqladmin -u root password '<password>'

Set Up git User

Gitorious needs a specific user which runs the services. Here it’s named git.
Gitorious uses SSH keys in authentication in Git push. The git user needs to
have a home directory, where the SSH keys are saved.
adduser --create-home git
Because git push is authenticated via git user, the git user must have a ssh
access to the server. So add git user to AllowGroups in /etc/ssh/sshd_config.

Clone the Gitorious Repository

Go to the directory where you want to download the application, for example to
/var/www. Use git to download Gitorious.
git clone git://gitorious.org/gitorious/mainline.git gitorious
Or if you want to install customized version of Gitorious named YouSource,
(currently only available inside the Jyväskylä University network):
git clone git://versotest.it.jyu.fi/verso/gitorious.git
Make a symbolic link of gitorious script to /usr/local/bin/.
ln -s /var/www/gitorious/script/gitorious /usr/local/bin/gitorious

Create the Directories for Repositories and Tarballs

Make the directories, where the git repositories and tarballs are saved.
mkdir /var/git
mkdir /var/git/repositories  
mkdir /var/git/tarballs  
mkdir /var/git/tarball-work
Change the owner of these and the application directories to git user.
chown -R git:git /var/git /var/www/gitorious

Install a Web Server

Gitorious is a web application, so you need a web server. Here we install
Apache, but you can use some other web server as well.
yum install -y httpd httpd-devel
Install also the mod_xsendfile module to get source tarball downloading working.
wget http://tn123.ath.cx/mod_xsendfile/mod_xsendfile.c
apxs -cia mod_xsendfile.c

Install and Configure Passenger

Install Phusion Passenger module to simplify Rails application deployment.
/opt/ruby-enterprise/bin/passenger-install-apache2-module
Follow the instructions as provided by the installation script.
Edit Apache configuration file /etc/httpd/conf/httpd.conf and add the lines
the installation script recommend, something like this:
LoadModule passenger_module /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.2.11/ext/apache2/mod_passenger.so
PassengerRoot /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.2.11  
PassengerRuby /opt/ruby-enterprise/bin/ruby
In the same file set DocumentRoot to <your-gitorious-root>/public, for example
/var/www/gitorious/public, and set your ServerName (ours is versotest.it.jyu.fi).
  ServerName versotest.it.jyu.fi
  DocumentRoot /var/www/gitorious/public
 
  # Enable X-SendFile for Gitorious repo archiving to work  
  XSendFile on  
  XSendFileAllowAbove on  
 
  <Directory /var/www/gitorious/public>  
     AllowOverride all  
     Options -MultiViews  
  </Directory>  
 
  ServerName versotest.it.jyu.fi
  DocumentRoot /var/www/gitorious/public  
 
  <Directory /var/www/gitorious/public>  
     AllowOverride all  
     Options -MultiViews  
  </Directory>  
Restart Apache and after that Passenger should recognize the application and
start it when accessing the web page through a web browser.

Set Up Gitorious

The git user runs all the Gitorious services. So from now on use git user:
sudo su git
Add these lines in the end of the git user’s ~/.bashrc file so that git user
can run ruby programs. Change the directory to match your Ruby installation
directory.
export RUBY_HOME=/opt/ruby-enterprise
export GEM_HOME=$RUBY_HOME/lib/ruby/gems/1.8/gems  
export PATH=$RUBY_HOME/bin:$PATH
Load new paths as a git user:
source ~/.bashrc

Make authorized_keys File

When someone tries to push to a repository through Gitorious, the user will be
looked up in the git user’s ~/.ssh/authorized_keys. If the user is found here,
the ssh connection is handled by the git-daemon process. We have to create this
file, but Gitorious will maintain it for us.
Make sure the permissions on authorized_keys are 600 and ~/.ssh are 700.
mkdir ~/.ssh
chmod 700 ~/.ssh  
touch ~/.ssh/authorized_keys  
chmod 600 ~/.ssh/authorized_keys

Configuration

Next go to your Gitorious root dir (for example cd /var/www/gitorious) and
make a directory for pid files.
mkdir -p tmp/pids
Make all the Gitorious scripts executable.
chmod ug+x script/*
Copy the configuration sample files and edit the settings. The files includes
good instructions.
cp config/database.sample.yml config/database.yml
cp config/gitorious.sample.yml config/gitorious.yml  
cp config/broker.yml.example config/broker.yml
If you installed customized YouSource, you have to edit these files too:
cp config/email.yml.example config/email.yml
cp script/ldap_settings.py.template script/ldap_settings.py
Install the remaining gems:
sudo rake gems:install
Create the database and schema:
rake db:create RAILS_ENV=production
rake db:migrate RAILS_ENV=production
Build the search index and start the search daemon:
rake ultrasphinx:configure RAILS_ENV=production
rake ultrasphinx:index RAILS_ENV=production  
rake ultrasphinx:daemon:start RAILS_ENV=production
Schedule Sphinx search engine to index the site automatically. Add to the
crontab, using crontab -e, the following line:
* * * * * cd /var/www/gitorious && /opt/ruby-enterprise/bin/rake ultrasphinx:index RAILS_ENV=production

Scripts

Copy git-daemon and git-ultrasphinx from doc/templates/centos to
/etc/init.d/ as root user.
You have to create gitorious-poller and stomp scripts on your own.

gitorious-poller Example File:

#!/bin/sh
#  
# poller       Startup script for Gitorious's poller  
#  
# chkconfig: - 86 15  
# description: Gitorious's poller script is simple worker that polls \  
#              tasks from stomp server queue and executes them.  
# processname: poller
 
/bin/su - git -c "cd /var/www/gitorious; RAILS_ENV=production ./script/poller $@"

stomp Example File:

#!/bin/sh
#  
# stomp        Startup script for stomp server   
#  
# chkconfig: - 85 15  
# description: Stomp server is simple task queue server that \  
#              uses stomp protocol.       
# processname: stomp  
# config: /etc/stompserver.conf
 
/bin/su - git -c "cd /var/www/gitorious; RAILS_ENV=production; stompserver -C /etc/stompserver.conf $@"

Start the Services

Go to /etc/init.d/ and give the scipts execute permissions:
sudo chmod 755 git-daemon git-ultrasphinx gitorious-poller stomp
Add services to start automatically on boot:
chkconfig --add stomp
chkconfig --add git-daemon  
chkconfig --add gitorious-poller  
chkconfig --add git-ultrasphinx  
chkconfig --add memcached
 
chkconfig stomp on  
chkconfig git-daemon on  
chkconfig gitorious-poller on  
chkconfig git-ultrasphinx on  
chkconfig memcached on
Now you can start the services:
service git-ultrasphinx start
service stomp start  
service memcached start  
service gitorious-poller start  
service git-daemon start  
service httpd restart
Now you should have Gitorious up and running! Go to your web page through a
browser and start using Gitorious.