xinitdでGit deamonを使う

参考にしたのはここ↓
http://yoshimov.com/?page=Git%2Fgit%A5%D7%A5%ED%A5%C8%A5%B3%A5%EB%A4%C7%A5%EA%A5%DD%A5%B8%A5%C8%A5%EA%A4%F2%B6%A6%CD%AD
http://d.hatena.ne.jp/tarurut/20101213/1292228704
http://d.hatena.ne.jp/tarurut/20101213

CentOSにgitとgit daemonを入れる

まずCentOSにgitを入れます

# sudo yum install git
# sudo yum install git-daemon

xinitdを使ってgit-daemonを起動

git-daemonはパスが通ってないのでので探す

# find / -name git-daemon

今回は以下のとろこにありました

/usr/libexec/git-core/git-daemon


次にxinitdを使ってgit-daemonを起動させます。
/etc/xinetd.d/ 内に git というファイル名で以下の内容を保存

# default: off
# description: The git daemon allows git repositories to be exported using # the git:// protocol.

service git
{
disable = no

# git is in /etc/services only on RHEL5+
type = UNLISTED
port = 9418

socket_type = stream
wait = no
user = nobody
server = /usr/libexec/git-core/git-daemon
server_args = --base-path=/var/lib/git --export-all --user-path=public_git --syslog --inetd --verbose
log_on_failure += USERID
# xinetd does not enable IPv6 by default
# flags = IPv6
}

変更点は

  • disable =yes

  →disable = no

  • #type = UNLISTED

  →type = UNLISTED

  • #port = 9418

  →port = 9418

xinitdをリスタートします

#sudo /etc/init.d/xinetd restart
xinetd を停止中: [ OK ]
xinetd を起動中: [ OK ]

起動したかを確認

# chkconfig --list | grep git
git: on

ポートの確認
Gitために開放したポートは9418/tcpなのでそれがあるか確認

# netstat -anp | grep 9418
tcp 0 0 0.0.0.0:9418 0.0.0.0:* LISTEN 28251/xinetd

使ってみる

あとは/var/lib/gitの下に公開用のリポジトリ(今回はtstrepos.git)をつくってクローンが使えるかチェックします。

# git clone git://localhost/tstrepos.git ./tstrepos.git
Cloning into ./tstrepos.git...

なんかうまくいかなかったら再度パッケージを入れ直すところから初めて見てください。
自分も2回目でうまくいきました。