Gitのレポジトリサーバをxinetdで立てる
昨日に引き続き、git-daemonです。
マニュアルを見ているとgit daemonはinetdで起動できるみたいなので、それならxinetdで立ててみるかなという気持ちになってきました。
git-daemon(1) Manual Page
http://www.kernel.org/pub/software/scm/git/docs/everyday.html
xinetdをインストール
うちの環境はCentOS5.2です。デフォルトでxinetdがインストールされていなかったので、まずインストールするところからスタート。
パッケージ xinetd はインストールされていません。
# yum install xinetd
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
xinetd x86_64 2:2.3.14-10.el5 base 125 k
Transaction Summary
=============================================================================
Install 1 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 125 k
Is this ok [y/N]: y
これでxintedはインストールされましたね。
続いて、xintedの起動と、次回から自動起動するようにchkconfigをonにしておく。
# /etc/init.d/xinetd start
xinetd を起動中: [ OK ]
xinetdが起動しました。
xinetdにgitを登録
さてgit-daemonがxinetd経由で、gitのポートにリクエストがあった時、適宜起動してくれるよう設定します。
....
git 9418/tcp # git pack transfer service
git 9418/udp # git pack transfer service
gitがインストールされている場合、/etc/servicesにはすでに登録されていると思います。
続いて/etc/xinetd.d/にgit用の設定ファイルを設置します。
内容は以下のように
# description: The git server offers access to git repositories
service git
{
disable = no
type = UNLISTED
port = 9418
socket_type = stream
wait = no
user = nobody
server = /usr/bin/git-daemon
server_args = --inetd --export-all --base-path=/var/git --enable=receive-pack
log_on_failure += USERID
}
以上で完了です。
レポジトリの追加
レポジトリの追加についても簡単にまとめておきます。
cd /tmp/hoge
git init
適当なところでローカルのgitレポジトリを作成する
git add .
git commit -m "1st commit."
そのリポジトリになんでも良いので1発コミットをしておく。
git clone --bare /tmp/hoge .hoge.git
touch hoge.git/git-daemon-export-ok
chown -R nobody:nobody hoge.git
公開用に設定してある/var/gitに移動し、公開用リポジトリ作成。 –bareオプションを忘れずに。
ディレクトリのオーナーをnobodyにしておく(/etc/xinetd/git-daemonで設定したユーザー)
以上です。
–
追記
参考にしたのはここ
Everyday GIT With 20 Commands Or So
http://www.kernel.org/pub/software/scm/git/docs/everyday.html
さらに
gitosis – Git リポジトリ群の管理とアクセス制御 vol.0
http://openbooth.org/archives/60.html
この辺を参考にしてもっと細やかな管理方法を会得したい。