UNPKG

epubjs

Version:

Render ePub documents in the browser, across many devices

85 lines (59 loc) 5.54 kB
<?xml version='1.0' encoding='utf-8'?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Pro Git - professional version control</title> <meta content="http://www.w3.org/1999/xhtml; charset=utf-8" http-equiv="Content-Type"/> <link href="stylesheet.css" type="text/css" rel="stylesheet"/> <style type="text/css"> @page { margin-bottom: 5.000000pt; margin-top: 5.000000pt; }</style> </head> <body class="calibre"> <h2 class="calibre4" id="calibre_pb_38">Git Daemon</h2> <p class="calibre3">For public, unauthenticated read access to your projects, you'll want to move past the HTTP protocol and start using the Git protocol. The main reason is speed. The Git protocol is far more efficient and thus faster than the HTTP protocol, so using it will save your users time.</p> <p class="calibre3">Again, this is for unauthenticated read-only access. If you're running this on a server outside your firewall, it should only be used for projects that are publicly visible to the world. If the server you're running it on is inside your firewall, you might use it for projects that a large number of people or computers (continuous integration or build servers) have read-only access to, when you don't want to have to add an SSH key for each.</p> <p class="calibre3">In any case, the Git protocol is relatively easy to set up. Basically, you need to run this command in a daemonized manner:</p> <pre class="calibre9"><code class="calibre10">git daemon --reuseaddr --base-path=/opt/git/ /opt/git/ </code></pre> <p class="calibre3"><code class="calibre10">--reuseaddr</code> allows the server to restart without waiting for old connections to time out, the <code class="calibre10">--base-path</code> option allows people to clone projects without specifying the entire path, and the path at the end tells the Git daemon where to look for repositories to export. If you're running a firewall, you'll also need to punch a hole in it at port 9418 on the box you're setting this up on.</p> <p class="calibre3">You can daemonize this process a number of ways, depending on the operating system you're running. On an Ubuntu machine, you use an Upstart script. So, in the following file</p> <pre class="calibre9"><code class="calibre10">/etc/event.d/local-git-daemon </code></pre> <p class="calibre3">you put this script:</p> <pre class="calibre9"><code class="calibre10">start on startup stop on shutdown exec /usr/bin/git daemon \ --user=git --group=git \ --reuseaddr \ --base-path=/opt/git/ \ /opt/git/ respawn </code></pre> <p class="calibre3">For security reasons, it is strongly encouraged to have this daemon run as a user with read-only permissions to the repositories - you can easily do this by creating a new user 'git-ro' and running the daemon as them. For the sake of simplicity we'll simply run it as the same 'git' user that Gitosis is running as.</p> <p class="calibre3">When you restart your machine, your Git daemon will start automatically and respawn if it goes down. To get it running without having to reboot, you can run this:</p> <pre class="calibre9"><code class="calibre10">initctl start local-git-daemon </code></pre> <p class="calibre3">On other systems, you may want to use <code class="calibre10">xinetd</code>, a script in your <code class="calibre10">sysvinit</code> system, or something else - as long as you get that command daemonized and watched somehow.</p> <p class="calibre3">Next, you have to tell your Gitosis server which repositories to allow unauthenticated Git server-based access to. If you add a section for each repository, you can specify the ones from which you want your Git daemon to allow reading. If you want to allow Git protocol access for your iphone project, you add this to the end of the <code class="calibre10">gitosis.conf</code> file:</p> <pre class="calibre9"><code class="calibre10">[repo iphone_project] daemon = yes </code></pre> <p class="calibre3">When that is committed and pushed up, your running daemon should start serving requests for the project to anyone who has access to port 9418 on your server.</p> <p class="calibre3">If you decide not to use Gitosis, but you want to set up a Git daemon, you'll have to run this on each project you want the Git daemon to serve:</p> <pre class="calibre9"><code class="calibre10">$ cd /path/to/project.git $ touch git-daemon-export-ok </code></pre> <p class="calibre3">The presence of that file tells Git that it's OK to serve this project without authentication.</p> <p class="calibre3">Gitosis can also control which projects GitWeb shows. First, you need to add something like the following to the <code class="calibre10">/etc/gitweb.conf</code> file:</p> <pre class="calibre9"><code class="calibre10">$projects_list = "/home/git/gitosis/projects.list"; $projectroot = "/home/git/repositories"; $export_ok = "git-daemon-export-ok"; @git_base_url_list = ('git://gitserver'); </code></pre> <p class="calibre3">You can control which projects GitWeb lets users browse by adding or removing a <code class="calibre10">gitweb</code> setting in the Gitosis configuration file. For instance, if you want the iphone project to show up on GitWeb, you make the <code class="calibre10">repo</code> setting look like this:</p> <pre class="calibre9"><code class="calibre10">[repo iphone_project] daemon = yes gitweb = yes </code></pre> <p class="calibre3">Now, if you commit and push the project, GitWeb will automatically start showing your iphone project.</p> </body> </html>