30.1.2 Gitolite的安装/升级

本节的标题为安装/升级,是因为Gitolite的安装和升级可以采用同样的步骤。

Gitolite安装可以在客户端执行,而不需要在服务器端操作,非常方便。远程安装Gitolite的前提是:

已经在服务器端创建了专有账号,如git。

管理员能够以git用户的身份通过公钥认证以无口令方式登录服务器。

安装和升级都可以按照下面的步骤进行:

(1)使用git下载Gitolite的源代码。


$git clone git://github.com/ossxp-com/gitolite.git


(2)进入gitolite/src目录,执行安装。


$cd gitolite/src

$./gl-easy-install git server admin


命令gl-easy-install的第一个参数git是服务器上创建的专用账号ID,第二个参数server是服务器IP或域名,第三个参数admin是管理员ID。

(3)首先显示版本信息。



you are upgrading(or installing first-time)to v1.5.4-22-g4024621

Note:getting '(unknown)' for the 'from' version should only happen once.

Getting '(unknown)' for the 'to' version means you are probably installing

from a tar file dump,not a real clone.This is not an error but it's nice to

have those version numbers in case you need support.Try and install from a clone


(4)自动创建名为admin的私钥/公钥对。创建的公钥/私钥对的名称来自于gl-easy-install命令的最后一个参数admin。



the next command will create a new keypair for your gitolite access

The pubkey will be/home/jiangxin/.ssh/admin.pub.You will have to choose a

passphrase or hit enter for none.I recommend not having a passphrase for

now,especiallyif you do not have a passphrase for the key which you are

already using to get server access!

Add one using 'ssh-keygen-p' after all the setup is done and you've

successfully cloned and pushed the gitolite-admin repo.After that,install

'keychain' or something similar,and add the following command to your bashrc

(since this is a non-default key)

ssh-add$HOME/.ssh/admin

This makes using passphrases very convenient.


(5)如果公钥已经存在,会弹出警告。



Hmmm…pubkey/home/jiangxin/.ssh/admin.pub exists;should I just(re-)use it?

IMPORTANT:once the install completes,thiskey can no longer be used to get

a command line on the server—it will be used by gitolite,for git access

only.If that is a problem,please ABORT now.

doc/6-ssh-troubleshooting.mkd will explain what is happening here,if you need

more info.


(6)自动修改客户端的.ssh/config文件,增加名为gitolite的别名主机。

即当访问主机gitolite时,会自动用名为admin.pub的公钥,以git用户的身份连接服务器。



creating settings for your gitolite access in/home/jiangxin/.ssh/config;

these are the lines that will be appended to your~/.ssh/config:

host gitolite

user git

hostname server

port 22

identityfile~/.ssh/admin


(7)上传脚本文件到服务器,完成服务器端软件的安装。


gl-dont-panic

100%3106 3.0KB/s 00:00

gl-conf-convert

100%2325 2.3KB/s 00:00

gl-setup-authkeys

100%1572 1.5KB/s 00:00

gitolite-hooked

100%0 0.0KB/s 00:00

update

100%4922 4.8KB/s 00:00


the gitolite rc file needs to be edited by hand.The defaults are sensible,

so if you wish,you can just exit the editor.

Otherwise,make any changes you wish and save it.Read the comments to

understand what is what—the rc file's documentation is inline.

Please remember this file will actually be copied to the server,and that all

the paths etc.represent paths on the server!


(8)自动调用vi编辑器打开.gitolite.rc文件,编辑结束后上传到服务器。

该配置文件为Perl语法,注意保持文件格式和语法。退出vi编辑器,输入"<ESC>:q"(不带引号)。以下为该配置文件中比较重要的设置,一般无须改变默认的配置。

〇$REPO_BASE="repositories";

用于设置Git服务器的根目录,默认是Git用户主目录下的repositories目录,可以使用绝对路径。所有Git库都将部署在该目录下。

〇$REPO_UMASK=0007;#gets you 'rwxrwx—-'

版本库创建使用的掩码。即新建立的版本库的权限为'rwxrwx—-'。

〇$GL_BIG_CONFIG=0;

如果授权文件非常复杂,更改此项配置为1,以免产生庞大的授权编译文件。

〇$GL_WILDREPOS=1;

默认支持通配符版本库授权。

(9)至此完成安装。