Sophie

Sophie

distrib > Mageia > 7 > armv7hl > media > core-release > by-pkgid > d8544620e4ac7bee48ddb48c85d55709 > files > 535

ikiwiki-3.20190228-1.mga7.noarch.rpm

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Hosting Ikiwiki with a master git repository on a remote machine</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />

<link rel="stylesheet" href="../style.css" type="text/css" />

<link rel="stylesheet" href="../local.css" type="text/css" />










</head>
<body>

<div class="page">

<div class="pageheader">
<div class="header">
<span>
<span class="parentlinks">

<a href="../index.html">ikiwiki</a>/ 

<a href="../tips.html">tips</a>/ 

</span>
<span class="title">
Hosting Ikiwiki with a master git repository on a remote machine

</span>
</span>



</div>









</div>





<div id="pagebody">

<div id="content" role="main">
<p>This tutorial explains how to set up a wiki such that:</p>

<ul>
<li>the machine running Ikiwiki is not the same as the one hosting the git repository;</li>
<li>changes can be done using CGI;</li>
<li>changes can be done using git (using ssh protocol).</li>
</ul>

<p>This configuration may be useful when:</p>

<ul>
<li>you do not want (or cannot) connect to the machine hosting your wiki using
<code>git</code> or <code>ssh</code>;</li>
<li>you do not want (or cannot) publish web content on the machine hosting you
remotely accessible git repository.</li>
</ul>

<p>I assume the <a href="../rcs.html">rcs</a> used is <a href="../rcs/git.html">git</a>, but it might be done for other rcs.</p>

<h1>Similar and related tips and problems</h1>

<ul>
<li><a href="./distributed_wikis.html">distributed wikis</a> References different way of distributing wikis (including this one).</li>
<li><a href="http://www.icanttype.org/blog/ikiwiki_git_remote_repo/">http://www.icanttype.org/blog/ikiwiki_git_remote_repo/</a> Similar to what I
am describing, excepted that you must be able to connect to the machine
hosting Ikiwiki using ssh.</li>
<li><span class="createlink">How to specify repository is on a remote host&#63;</span> My solution
solves the problem described here, excepted that svn is used there, and in
the comments, Joey advice not to do this with svn.</li>
<li><span class="createlink">how to setup ikiwiki on a remote host</span> My solution might answer this
problem.</li>
</ul>

<h1>Overview</h1>

<p>By default, when creating a wiki, Ikiwiki creates and uses two repositories: a
bare repository, and a « slave » repository, used as the source to render the
wiki. All of these are on the same machine.</p>

<p>Instead of having the bare repository hosted on the same machine, we will host
it on a remote machine, and tell Ikiwiki to use it instead of its local one. We
will also ensure that the wiki is rendered whenever a commit is done to the git
repository.</p>

<p><a href="./Hosting_Ikiwiki_and_master_git_repository_on_different_machines/separate-web-git-servers.svg"><img src="./Hosting_Ikiwiki_and_master_git_repository_on_different_machines/separate-web-git-servers.svg" width="400" class="img" /></a></p>

<h1>Conventions</h1>

<ul>
<li>We are building a wiki called <em>SITE</em>.</li>
<li>The machine running Ikiwiki and a web server is called the <em>Ikiwiki machine</em>.</li>
<li>The machine hosting the git repository is called the <em>git machine</em>. Users can
make git pull and push to this machine.</li>
</ul>

<h1>Let's go!</h1>

<h2>Creating ssh keys on the Ikiwiki machine</h2>

<ul>
<li>Create a pair of ssh keys, not password-protected (as they will be used by
script). Let's call them <code>id_SITE</code> and <code>id_SITE.pub</code>. These keys will be used
by the ikiwiki machine to connect to the git machine.</li>
</ul>

<h2>Creating and setting up a repository on the git machine</h2>

<ul>
<li>Create a repository <code>SITE.git</code> on the git machine (using <code>git init --bare</code>),
and ensure that public key <code>id_SITE.pub</code> can pull from and push to this
repository (using <code>~/.ssh/config</code> or by setting the right permissions on
gitolite or gitosis).</li>
</ul>

<h2>Creating the wiki on the ikiwiki machine</h2>

<ul>
<li>Create the wiki following <a href="../setup.html">the regular procedure</a>. You should have,
among others, a directory <code>SITE.git</code>, being the master git repository, and a
directory <code>SITE</code>, clone of <code>SITE.git</code>, used as source directory to render the
wiki.</li>
<li>Ensure that your web server can serve the rendered wiki, and that changes can
be done with CGI.</li>
</ul>

<h2>Configuring the wiki on the wiki machine so that it uses the repository of the git machine</h2>

<ul>
<li><p>Configure ssh so that it uses the ssh key <code>id_SITE</code> to connect to the git
machine: add the following lines to file <code>~/.ssh/config</code> on the ikiwiki
machine:</p>

<pre><code>Host server.name.of.the.git.machine
    User git-machine-user
    IdentityFile ~/.ssh/id_SITE
</code></pre></li>
<li><p>Configure the local copy <code>SITE</code> of the wiki (on the ikiwiki machine) to use
the remote git repository instead of the local <code>SITE.git</code>. To do so, in the
file <code>SITE/.git/config</code>, replace the lines:</p>

<pre><code>[remote "origin"]
       url = /path/to/SITE.git
       fetch = +refs/heads/*:refs/remotes/origin/*
</code></pre>

<p>by the lines:</p>

<pre><code>[remote "origin"]
        url = git-machine-user@server.name.of.the.git.machine:SITE.git
        fetch = +refs/heads/*:refs/remotes/origin/*
</code></pre></li>
<li><p>In this repository (<code>SITE</code>), run <code>git pull</code> and <code>git push</code> to ensure that
everything works fine. It <em>works fine</em> when you will be able to run <code>git
pull</code> and <code>git push</code> without user interaction.</p></li>
<li><p>Disable the <code>post-update</code> hook in ikiwiki: it is used if the git commits are
done on this machine, which is no longer the case. To do so, in file
<code>SITE.setup</code>, comment the line:</p>

<pre><code>git_wrapper =&gt; '/path/to/SITE.git/hooks/post-update',
</code></pre></li>
<li><p>Tell Ikiwiki to push to the ikiwiki machine when a commit is done by the web
(CGI). To do so, in file <code>SITE.setup</code>, add the line:</p>

<pre><code>git_wrapper_background_command =&gt; 'git push',
</code></pre></li>
<li><p>Enable plugin <a href="http://ikiwiki.info/plugins/pingee/">pingee</a>. It allows git
(on the git machine) to tell ikiwiki to update and rebuild the wiki when
commits are done on the git repository, using only an http connection. To do
so, add <code>pingee</code> to the list of enabled plugins (variable <code>add_plugins</code> in
file <code>SITE.setup</code>).</p></li>
<li><p>Rebuild the wiki (since you chaned the setup file <code>SITE.setup</code>).</p>

<pre><code>ikiwiki --setup SITE.setup --rebuild --verbose
</code></pre></li>
</ul>

<h2>Configure the git repository (on the git machine) to update the wiki after a push</h2>

<p>Add in the <code>post-receive</code> hook (file <code>SITE.git/hooks/post-receive</code>):</p>

<pre><code>  git log -1 --format=format:%ae HEAD | grep -e '@web&#036;' -e 'USER@HOST' ||  wget "http://WIKI-URL/ikiwiki.cgi?do=ping" -O /dev/stdout
</code></pre>

<p>If your wiki is password protected, use:</p>

<pre><code>  git log -1 --format=format:%ae HEAD | grep -e '@web&#036;' -e 'USER@HOST' ||  wget "http://LOGIN:PASSWORD@WIKI-URL/ikiwiki.cgi?do=ping" -O /dev/stdout
</code></pre>

<p>The bit before <code>wget</code> is here to prevent updating the wiki while it is
updating, which can lead to a deadlock. Indeed, when the wiki is edited via
web, or a tag page is automatically added, IkiWiki pushes the changes to the
Git machine. Then, the hook on this latter machine tries to pull changes from
the IkiWiki machine, and here is the deadlock. Explanations of the command:</p>

<ul>
<li><code>git log -1 --format=format:%ae HEAD</code>: Looks for the user name of the
latest commit.</li>
<li><code>grep -e '@web&#036;' -e 'USER@HOST': Check whether this last commit was pushed
from the IkiWiki machine (change</code>USER@HOST` to the appropriate string).</li>
<li><code>wget ...</code>: If the last commit does not come from the IkiWiki machine
(which means it comes from another machine), update the wiki.</li>
</ul>

<h2>Going further</h2>

<ul>
<li><em>Web server on a third machine</em> It should be possible to use a third machine
to host the web server, using <a href="./Git_repository_and_web_server_on_different_hosts.html">this documentation</a>.</li>
<li><p><em>Using <a href="https://github.com/sitaramc/gitolite">gitolite</a> to manage
repositories on the git machine</em> Simply replace the manipulations of git on
the git machine by the corresponding manipulations using gitolite.</p>

<ul>
<li><p>With gitolite, you can use this line in a <code>post-update</code> hook:</p>

<p><code>[ x"&#036;GL_USER" = x"</code><em><code>gitolite-user</code></em><code>" ] || wget ...</code> where <em>gitolite-user</em> is the name of the public key registered through gitolite.</p>

<p>Thus, you filter out precisely the events that originate from the server-to-be-pinged, no matter what the commit id says. (For example, if you push commits you created on a local CGI ikiwiki, they'd be called '@web' as well).</p></li>
</ul></li>
</ul>

</div>







</div>

<div id="footer" class="pagefooter" role="contentinfo">

<div id="pageinfo">






<div id="backlinks">
Links:

<a href="./distributed_wikis.html">distributed wikis</a>


</div>






<div class="pagedate">
Last edited <span class="date">Tue Feb 26 23:01:54 2019</span>
<!-- Created <span class="date">Mon Jul 22 20:38:20 2013</span> -->
</div>

</div>


<!-- from ikiwiki -->
</div>

</div>

</body>
</html>