Difference between revisions of "GitSetup"

From PDP/Grid Wiki
Jump to navigationJump to search
(details of git setup on span)
Line 121: Line 121:
 
The apache configuration in /etc/httpd/conf.d/git.conf:
 
The apache configuration in /etc/httpd/conf.d/git.conf:
 
  Alias /git /srv/git/gitweb
 
  Alias /git /srv/git/gitweb
 
+
 
  <Directory /srv/git/gitweb >
 
  <Directory /srv/git/gitweb >
 
         Options Indexes FollowSymLinks ExecCGI  
 
         Options Indexes FollowSymLinks ExecCGI  

Revision as of 17:37, 16 February 2010

Git setup on span

The goal is to have a a shared, writeable repository for files controlling the setup of virtual machines, in particular site-info.def and friends, and firstboot scripts.

The git version control software has very good branch management and is fully distributed in setup. All actions are committed to a local repository, and can be pushed to (or pulled from) other repositories.

Gitosis

To have a shared writable repository nonetheless, gitosis is installed on span.nikhef.nl

for setting up gitosis are found on-line and these were followed almost literally.

git clone git://eagain.net/gitosis.git
cd gitosis/
sudo python setup.py install
sudo adduser -r -d /srv/git -c 'git version control' --shell /bin/sh git
sudo -u git gitosis-init < id-rsa.pub

The management of gitosis is through git!

git clone git@span:gitosis-admin.git
<manage the config file and keydir>
git commit
git push

Now it becomes interesting. After configuring write access to the 'siteinfo' repository, the local siteinfo repository was configured to push to git@span as well:

cd ~/src/siteinfo
git remote add shared git@span.nikhef.nl:siteinfo.git
git push shared

Git-daemon

It is convenient to have read-only anonymous access to selected repositories as well. First, through git-daemon. This comes with the git distribution so the following init script was installed as /etc/init.d/git-daemon.

#!/bin/sh
#
# Startup/shutdown script for Git Daemon
#
#   Linux chkconfig stuff:
#
#   chkconfig: 345 56 10
#   description: Startup/shutdown script for Git Daemon
#
. /etc/init.d/functions

DAEMON=git-daemon
ARGS='--base-path=/srv/git/repositories --detach --user=git --group=git'

prog=git-daemon

start () {
    echo -n $"Starting $prog: "

    # start daemon
    daemon $DAEMON $ARGS
        RETVAL=$?
    echo
    [ $RETVAL = 0 ] && touch /var/lock/git-daemon
    return $RETVAL
}

stop () {
    # stop daemon
    echo -n $"Stopping $prog: "
    killproc $DAEMON
    RETVAL=$?
    echo
    [ $RETVAL = 0 ] && rm -f /var/lock/git-daemon
}

restart() {
    stop
    start
}

case $1 in
    start)
        start
    ;;
    stop)
        stop
    ;;
    restart)
        restart
    ;;
    status)
        status $DAEMON
        RETVAL=$?
    ;;
    *)

    echo $"Usage: $prog {start|stop|restart|status}"
    exit 3
esac

exit $RETVAL


The git-daemon will only export repositories that have the file named

git-daemon-export-ok

in the root, and gitosis-admin is thereby excluded from public view. This file is not under version control.

Gitweb

instructions were found on Gitweb wiki.

The git installation on span is from DAG:

git-1.5.2.1-1.el5.rf

The web application gitweb.cgi is not included in the rpm, so it was built from the sources in the source rpm. The variable GITWEB_EXPORT_OK indicates the file name that flags public visibility for repositories, just like git-daemon.

wget http://dag.wieers.com/rpm/packages/git/git-1.5.2.1-1.rf.src.rpm
rpm -i git-1.5.2.1-1.rf.src.rpm 
cd rpmbuild/SOURCES/
tar xfj git-1.5.2.1.tar.bz2 
cd git-1.5.2.1
make GITWEB_PROJECTROOT=/srv/git/repositories GITWEB_EXPORT_OK=git-daemon-export-ok prefix=/usr gitweb/gitweb.cgi
sudo cp gitweb/gitweb.* /srv/git/gitweb/

The apache configuration in /etc/httpd/conf.d/git.conf:

Alias /git /srv/git/gitweb

<Directory /srv/git/gitweb >
       Options Indexes FollowSymLinks ExecCGI 
	AddHandler cgi-script cgi
       AllowOverride None
	DirectoryIndex gitweb.cgi
	RewriteEngine On
	RewriteBase /git
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteRule ^.* /gitweb.cgi/$0 [L,PT]
</Directory>

The repositories can be browsed at http://span.nikhef.nl/git/.