Projet

Général

Profil

L'installation de gitolite » Historique » Version 3

Version 2 (Yanick Delarbre, 09/11/2011 12:30) → Version 3/11 (Jocelyn Dealande, 08/03/2013 12:23)

h1. Gitolite

h2. L'installation du serveur gitolite

<pre>
# dpkg-reconfigure locales Règles le warning à propos des locales non configurés
#La clé de l'admin
client$ .ssh/id_rsa.pub root@rhizome-fai.net:/tmp/nebula.pub
server# apt-get install gitolite -y
server# su - gitolite
#Initialisation du repository admin
gitolite@server$ gl-setup /tmp/nebula.pub
</pre>

h2. La configuration de gitolite

<pre>
client$ git clone gitolite@rhizome-fai.tetaneutral.net:gitolite-admin.git
client$ cd gitolite-admin
#Les clés des clients
client$ mv cle.pub key/
#La configuration de chaque repository
client$ vim conf/gitolite.conf
repo gitolite-admin
RW+ = user

repo testing
RW+ = @all

repo agregation
RW+ = user nebula jocelyn fernando
R = daemon

client$ git add conf/gitolite.conf key/*
client$ git commit -m "add repo agregation + git-daemon in R"
#Note: toutes la confiration s'applique grâce à un hook. Donc il suffit de "pusher" la configuration vers le serveur
client$ git push

</pre>

h2. Rendre le le(s) repository(s) public

<pre>
server# apt-get install git-daemon-run -y
server# vim /etc/init.d/git-daemon
</pre>

Le fichier git-daemon pour éviter d'utliser sv.

<pre>
#!/bin/sh

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:\
/usr/bin:/usr/lib/git-core
NAME=git-daemon
PIDFILE=/var/run/$NAME.pid
DESC="git daemon"
DAEMON=/usr/lib/git-core/git-daemon
DAEMON_OPTS="--base-path=/var/lib/gitolite/repositories --verbose \
--syslog --detach --pid-file=$PIDFILE --user=gitolite \
--group=nogroup --enable=receive-pack"

test -x $DAEMON || exit 0

[ -r /etc/default/git-daemon ] && . /etc/default/git-daemon

. /lib/lsb/init-functions

start_git() {
start-stop-daemon --start --quiet --pidfile $PIDFILE \
--startas $DAEMON -- $DAEMON_OPTS
}

stop_git() {
start-stop-daemon --stop --quiet --pidfile $PIDFILE
rm -f $PIDFILE
}

status_git() {
start-stop-daemon --stop --test --quiet --pidfile $PIDFILE >/dev/null 2>&1
}

case "$1" in
start)
log_begin_msg "Starting $DESC"
start_git
log_end_msg 0
;;
stop)
log_begin_msg "Stopping $DESC"
stop_git
log_end_msg 0
;;
status)
log_begin_msg "Testing $DESC: "
if status_git
then
log_success_msg "Running"
exit 0
else
log_failure_msg "Not running"
exit 1
fi
;;
restart|force-reload)
log_begin_msg "Restarting $DESC"
stop_git
sleep 1
start_git
log_end_msg 0
;;
*)
echo "Usage: $0 {start|stop|restart|force-reload|status}" >&2
exit 1
;;
esac

exit 0
</pre>

Et enfin, rendre ce service "automatique":
<pre>
server# update-rc.d git-daemon defaults default
</pre>

h2. Pour cloner le repository soit en public avec un utilisateur (dont la clé a déjà été copier vers le repository-admin)

<pre>
client_git_public$ git clone git://rhizome-fai.tetaneutral.net/agregation.git
client_git_user$ git clone gitolite@rhizome-fai.tetaneutral.net:agregation.git

</pre>

h2. Les sources

http://doc.ubuntu-fr.org/gitolite#rendre_un_depot_public
http://computercamp.cdwilson.us/git-gitolite-git-daemon-gitweb-setup-on-ubunt