Home | Mirror | Search

第 10 章 git-daemon - A really simple server for git repositories

目錄

1. inet.conf / xinetd
2. git-daemon-run
3. Testing

在 /home/neo/test 上運行 git 守護進程

	
git daemon --verbose --export-all --enable=receive-pack --base-path=/home/neo/test
	
	

for a read-only repo:

	
git daemon –verbose –export-all –base-path=/home/repo/pub –reuseaddr
	
	

for a repo with ‘push’ allowed:

git daemon –verbose –export-all –base-path=/home/repo/pub –reuseaddr –enable=receive-pack

And need to add the following in XX.git/.git/config

[receive]
denyCurrentBranch = ignore
	

1. inet.conf / xinetd

過程 10.1. git-daemon

  1. /etc/shells

    /etc/shells 最後一行添加 '/usr/bin/git-shell'

    $ grep git /etc/shells
    /usr/bin/git-shell
    				
  2. add new user 'git' and 'gitroot' for git

    you need to assign shell with /usr/bin/git-shell

    $ sudo adduser git --shell /usr/bin/git-shell
    $ sudo adduser gitroot --ingroup git --shell /bin/bash
    				

    /etc/passwd

    $ grep git /etc/passwd
    git:x:1001:1002:,,,:/home/git:/usr/bin/git-shell
    gitroot:x:1002:1002:,,,:/home/gitroot:/bin/bash
    				
  3. /etc/services

    $ grep 9418 /etc/services
    git             9418/tcp                        # Git Version Control System
    				
  4. /etc/inet.conf

    $ grep git /etc/inet.conf
    git     stream  tcp     nowait  nobody \
      /usr/bin/git-daemon git-daemon --inetd --syslog --export-all /home/gitroot
    				

    reload inetd

    $ sudo pkill -HUP inetd
    				
  5. xinetd

    目前的Linux逐漸使用xinetd.d替代inet.conf,如Redhat系列已經不再使用inet.conf, Ubuntu系列發行版已經不預裝inet與xinetd

    $ apt-cache search xinetd
    globus-gfork-progs - Globus Toolkit - GFork Programs
    rlinetd - gruesomely over-featured inetd replacement
    update-inetd - inetd configuration file updater
    xinetd - replacement for inetd with many enhancements
    
    $ sudo apt-get install xinetd
    				

    /etc/xinetd.d/

    $ cat /etc/xinetd.d/git
    # default: off
    # description: The git server offers access to git repositories
    service git
    {
            disable = no
            type            = UNLISTED
            port            = 9418
            socket_type     = stream
            protocol 		= tcp
            wait            = no
            user            = git
            server          = /usr/bin/git-daemon
            server_args     = --inetd --export-all --base-path=/home/gitroot/
            log_on_failure  += USERID
    }
    				

    reload xinitd

    $ sudo /etc/init.d/xinetd reload
     * Reloading internet superserver configuration xinetd                                       [ OK ]
    				
comments powered by Disqus