Mac で git-daemon
Mac OS X で git-daemon を起動時に立ち上げたい。
とりあえず /Users/yuanying/Documents/temp/git にある bare な gitレポジトリ /Users/yuanying/Documents/temp/git/test.gitを、
$ git clone git://example.com/test.git
とかしてクライアントから pull したい。
git-daemon の起動
ベースディレクトリを指定して git-daemon を起動してやれば、 その下にあるgitレポジトリを公開できるぽい。
$ /opt/local/bin/git-daemon --verbose --export-all --user=yuanying --group=staff --base-path=/Users/yuanying/Documents/temp/git
で起動してみる。
ちゃんと動いてるか git clone してみる。
launch ファイルの作成
OS X 起動時に git-datemon が起動するように、launchファイルを作成する。 Lingon を使うと簡単ぽい。
以下のようなファイルを作成する。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>/opt/local/bin:$PATH</string>
</dict>
<key>Label</key>
<string>local.git.daemon</string>
<key>OnDemand</key>
<false/>
<key>ProgramArguments</key>
<array>
<string>/opt/local/bin/git-daemon</string>
<string>--verbose</string>
<string>--export-all</string>
<string>--user=yuanying</string>
<string>--group=staff</string>
<string>--base-path=/Users/yuanying/Documents/temp/git</string>
</array>
</dict>
</plist>
これを /Library/LaunchDaemons/local.git.daemon.plist という名前で保存。
MacPorts からインストールした git は、 launchdから起動したときにパスが通っていないので、環境変数PATHを設定してやる必要がある。
launchctl で起動してみる。
$ sudo launchctl load -w /Library/LaunchDaemons/local.git.daemon.plist
$ $ ps aux | grep git
yuanying 15439 0.0 0.0 78652 752 ?? Ss 2:46PM 0:00.00 /opt/local/bin/git-daemon --export-all --user=yuanying --group=staff --base-path=/Users/yuanying/Documents/temp/git
ちゃんと動いてる。
$ git clone git://localhost/test2.git foo
Initialized empty Git repository in /Users/yuanying/Documents/temp/test2/foo/.git/
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (3/3), done.
おk。