http://pool.wiki.guifi.net/w/index.php?title=Cloudy_plug-ins&feed=atom&action=historyCloudy plug-ins - Revision history2024-03-29T09:47:59ZRevision history for this page on the wikiMediaWiki 1.22.0http://pool.wiki.guifi.net/w/index.php?title=Cloudy_plug-ins&diff=3545&oldid=prevAl: 3 revisions: Importing all articles from english wiki2015-07-22T22:58:08Z<p>3 revisions: Importing all articles from english wiki</p>
<table class='diff diff-contentalign-left'>
<tr style='vertical-align: top;'>
<td colspan='1' style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan='1' style="background-color: white; color:black; text-align: center;">Revision as of 22:58, 22 July 2015</td>
</tr><tr><td colspan='2' style='text-align: center;'><div class="mw-diff-empty">(No difference)</div>
</td></tr></table>Alhttp://pool.wiki.guifi.net/w/index.php?title=Cloudy_plug-ins&diff=3544&oldid=prevConxuro at 18:22, 12 May 20152015-05-12T18:22:53Z<p></p>
<table class='diff diff-contentalign-left'>
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr style='vertical-align: top;'>
<td colspan='2' style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black; text-align: center;">Revision as of 18:22, 12 May 2015</td>
</tr><tr><td colspan="2" class="diff-lineno">Line 377:</td>
<td colspan="2" class="diff-lineno">Line 377:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>[[<del class="diffchange diffchange-inline">Categoria</del>:Cloudy]]</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>[[<ins class="diffchange diffchange-inline">Category</ins>:Cloudy]]</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>[[ca:Cloudy_plug-ins]]</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>[[ca:Cloudy_plug-ins]]</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>[[es:Cloudy_plug-ins]]</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>[[es:Cloudy_plug-ins]]</div></td></tr>
</table>Conxurohttp://pool.wiki.guifi.net/w/index.php?title=Cloudy_plug-ins&diff=3543&oldid=prevConxuro at 15:47, 22 April 20152015-04-22T15:47:46Z<p></p>
<table class='diff diff-contentalign-left'>
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr style='vertical-align: top;'>
<td colspan='2' style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black; text-align: center;">Revision as of 15:47, 22 April 2015</td>
</tr><tr><td colspan="2" class="diff-lineno">Line 10:</td>
<td colspan="2" class="diff-lineno">Line 10:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>=== A brief introduction ===</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>=== A brief introduction ===</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del style="font-weight: bold; text-decoration: none;"></del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del style="font-weight: bold; text-decoration: none;"></del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del style="font-weight: bold; text-decoration: none;">= Service Addition in Cloudy =</del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del style="font-weight: bold; text-decoration: none;"></del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del style="font-weight: bold; text-decoration: none;">== A brief introduction ==</del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>This guide will walk you through the process of adding a new service to Cloudy.</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>This guide will walk you through the process of adding a new service to Cloudy.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>In order to be clear and provide examples, we are going to be integrating a very simple service showing snippets of code along the way.</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>In order to be clear and provide examples, we are going to be integrating a very simple service showing snippets of code along the way.</div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">To follow the tutorial or to add complex services, will be nice any knowledge of Bash<ref name="Bash">(http://www.tldp.org/LDP/Bash-Beginners-Guide/Bash-Beginners-Guide.pdf)</ref> and PHP<ref name="PHP">(https://php.net/manual/es/index.php)</ref>.</ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>For the sake of simplicity, we will use <del class="diffchange diffchange-inline">[</del>https://github.com/mvdan/pastecat <del class="diffchange diffchange-inline">Pastecat]</del>. It is a good candidate because:</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>For the sake of simplicity, we will use <ins class="diffchange diffchange-inline">Pastecat<ref name="Pastecat">(</ins>https://github.com/mvdan/pastecat<ins class="diffchange diffchange-inline">)</ref></ins>. It is a good candidate because:</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>* It's a standalone program</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>* It's a standalone program</div></td></tr>
<tr><td colspan="2" class="diff-lineno">Line 28:</td>
<td colspan="2" class="diff-lineno">Line 24:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>* It's very lightweight on resources</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>* It's very lightweight on resources</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>== <del class="diffchange diffchange-inline">1. </del>Getting the binary ==</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>==<ins class="diffchange diffchange-inline">= </ins>Getting the binary <ins class="diffchange diffchange-inline">=</ins>==</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>The first thing we have to figure out is how to download and install the binary on Cloudy. Most software out there is already available as a package on Debian, but Pastecat isn't. If it were, it would be a matter of just running the command <code>apt-get install pastecat</code> from PHP. Therefore we'll have to get it from someplace else.</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>The first thing we have to figure out is how to download and install the binary on Cloudy. Most software out there is already available as a package on Debian, but Pastecat isn't. If it were, it would be a matter of just running the command <code>apt-get install pastecat</code> from PHP. Therefore we'll have to get it from someplace else.</div></td></tr>
<tr><td colspan="2" class="diff-lineno">Line 48:</td>
<td colspan="2" class="diff-lineno">Line 44:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>* Debian packages often contain small patches and fixes</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>* Debian packages often contain small patches and fixes</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>== <del class="diffchange diffchange-inline">2. </del>Testing it out ==</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>==<ins class="diffchange diffchange-inline">= </ins>Testing it out <ins class="diffchange diffchange-inline">=</ins>==</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>Before adding Pastecat as a Cloudy service, we can configure and start it ourselves directly (i.e. manually), to see if it works and how. This way we can better understand what configuration options or command line parameters are we will need to run it as a service, and also to manage it once it is running.</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>Before adding Pastecat as a Cloudy service, we can configure and start it ourselves directly (i.e. manually), to see if it works and how. This way we can better understand what configuration options or command line parameters are we will need to run it as a service, and also to manage it once it is running.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>== <del class="diffchange diffchange-inline">3. </del>Adding the controller ==</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>==<ins class="diffchange diffchange-inline">= </ins>Adding the controller <ins class="diffchange diffchange-inline">=</ins>==</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>In <code>web/plug/controllers</code> we have one PHP file per service, which we call &quot;the controller&quot;. This is the code that will run when we enter the services page on the Cloudy web interface.</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>In <code>web/plug/controllers</code> we have one PHP file per service, which we call &quot;the controller&quot;. This is the code that will run when we enter the services page on the Cloudy web interface.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>=== <del class="diffchange diffchange-inline">3.1. </del>Adding the index function ===</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>===<ins class="diffchange diffchange-inline">= </ins>Adding the index function <ins class="diffchange diffchange-inline">=</ins>===</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>We also want our service to be integrated in the Cloudy web structure. To do this, a few PHP scripts need to be created and added to our device. Altogether, and by the time being, we'll need to create a total of 2 scripts: <code>pastecat.PHP</code> and <code>pastecat.menu.PHP</code>. The first one is the controller itself, this is, the script that renders the page and has all the information such as buttons or redirections. The other one is what allows our service to show up in the upper menu bar of Cloudy's web interface.</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>We also want our service to be integrated in the Cloudy web structure. To do this, a few PHP scripts need to be created and added to our device. Altogether, and by the time being, we'll need to create a total of 2 scripts: <code>pastecat.PHP</code> and <code>pastecat.menu.PHP</code>. The first one is the controller itself, this is, the script that renders the page and has all the information such as buttons or redirections. The other one is what allows our service to show up in the upper menu bar of Cloudy's web interface.</div></td></tr>
<tr><td colspan="2" class="diff-lineno">Line 83:</td>
<td colspan="2" class="diff-lineno">Line 79:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>In our Cloudy system, these files must be placed at <code>/var/local/cDistro/plug/</code> the first one at <code>menus</code> directory and the second at <code>controllers</code> directory. Once we've done this, we can go to our Cloudy system and access our new Pastecat.</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>In our Cloudy system, these files must be placed at <code>/var/local/cDistro/plug/</code> the first one at <code>menus</code> directory and the second at <code>controllers</code> directory. Once we've done this, we can go to our Cloudy system and access our new Pastecat.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>=== <del class="diffchange diffchange-inline">3.2. </del>Making the controller install the service ===</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>===<ins class="diffchange diffchange-inline">= </ins>Making the controller install the service <ins class="diffchange diffchange-inline">=</ins>===</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>As said before, this step is made much more easier if the service is packaged in Debian. Since Pastecat isn't, we'll have to do it manually. This usually involves a combination of <code>wget</code>, <code>mv</code> and <code>chmod</code>. It is generally a good idea to keep the service's files under <code>/opt/SERVICENAME</code>.</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>As said before, this step is made much more easier if the service is packaged in Debian. Since Pastecat isn't, we'll have to do it manually. This usually involves a combination of <code>wget</code>, <code>mv</code> and <code>chmod</code>. It is generally a good idea to keep the service's files under <code>/opt/SERVICENAME</code>.</div></td></tr>
<tr><td colspan="2" class="diff-lineno">Line 143:</td>
<td colspan="2" class="diff-lineno">Line 139:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>We can see how the lasts steps are done within the same function, allowing us to install the software in the device.</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>We can see how the lasts steps are done within the same function, allowing us to install the software in the device.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>=== <del class="diffchange diffchange-inline">3.3 </del>Making the controller use Pastecat ===</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>===<ins class="diffchange diffchange-inline">= </ins>Making the controller use Pastecat <ins class="diffchange diffchange-inline">=</ins>===</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>== <del class="diffchange diffchange-inline">3.3.1 </del>Start the service ==</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>==<ins class="diffchange diffchange-inline">=== </ins>Start the service <ins class="diffchange diffchange-inline">===</ins>==</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>The next thing we want is our software to be used through the web interface. In order to do this, we will include a new option to the main page of pastecat, and also integrate a new function to the controller script to manage the binary. We will add the button like this:</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>The next thing we want is our software to be used through the web interface. In order to do this, we will include a new option to the main page of pastecat, and also integrate a new function to the controller script to manage the binary. We will add the button like this:</div></td></tr>
<tr><td colspan="2" class="diff-lineno">Line 246:</td>
<td colspan="2" class="diff-lineno">Line 242:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>LOGFILE=&quot;/dev/null&quot;</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>LOGFILE=&quot;/dev/null&quot;</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>PCUSER=&quot;nobody</pre></div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>PCUSER=&quot;nobody</pre></div></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>== <del class="diffchange diffchange-inline">3.3.2 </del>Stop the service ==</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> </div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins class="diffchange diffchange-inline">===</ins>== Stop the service <ins class="diffchange diffchange-inline">===</ins>==</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>Sometimes, we may also want to stop out service, so we will provide a button to do so. The first thing would be creating the button, but if we think a little, we will figure out that before doing this, we need a way to know if our service is running. In addition, we also need a way to stop our service. Since we are running on Linux, we can easily achieve that by using the <code>kill</code> command. The thing is that to use this command, we need the Process ID (PID). Luckily for us, we already kept this number when we created the pastecat server with <code>pidpc=$(eval $cmd)</code>.</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>Sometimes, we may also want to stop out service, so we will provide a button to do so. The first thing would be creating the button, but if we think a little, we will figure out that before doing this, we need a way to know if our service is running. In addition, we also need a way to stop our service. Since we are running on Linux, we can easily achieve that by using the <code>kill</code> command. The thing is that to use this command, we need the Process ID (PID). Luckily for us, we already kept this number when we created the pastecat server with <code>pidpc=$(eval $cmd)</code>.</div></td></tr>
<tr><td colspan="2" class="diff-lineno">Line 308:</td>
<td colspan="2" class="diff-lineno">Line 305:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>Now we can create a pastecat instance server and stop it. However, there is still something missing: make the other users see our service. And this is why we are using avahi.</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>Now we can create a pastecat instance server and stop it. However, there is still something missing: make the other users see our service. And this is why we are using avahi.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>== <del class="diffchange diffchange-inline">4 </del>Avahi service publishing ==</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>==<ins class="diffchange diffchange-inline">= </ins>Avahi service publishing <ins class="diffchange diffchange-inline">=</ins>==</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>On of the best things in Cloudy is the facility of publishing our service as a publication in the avahi network, allowing other users to know what we are offering and joining our service. To do this, we first need to add a few lines to the PHP controller, just after we've called the controller to start the pastecat instance. We will add the following lines:</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>On of the best things in Cloudy is the facility of publishing our service as a publication in the avahi network, allowing other users to know what we are offering and joining our service. To do this, we first need to add a few lines to the PHP controller, just after we've called the controller to start the pastecat instance. We will add the following lines:</div></td></tr>
<tr><td colspan="2" class="diff-lineno">Line 361:</td>
<td colspan="2" class="diff-lineno">Line 358:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>setFlash($flash);</pre></div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>setFlash($flash);</pre></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>These lines will be added just after the <code>execute_program_detached($cmd)</code> sentence in the stop function.</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>These lines will be added just after the <code>execute_program_detached($cmd)</code> sentence in the stop function.</div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">=== Final ===</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">Finally just comment that all the files implemented in this tutorial can be found in a Github repository, linked in the External Link section, also with this tutorial in Markdown format (md).</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">== References ==</ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"><references/></ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
</table>Conxurohttp://pool.wiki.guifi.net/w/index.php?title=Cloudy_plug-ins&diff=3542&oldid=prevRogerpueyo: Created page. Translated first section from Catalan page and added pastecat.md documentation.2015-04-22T15:07:15Z<p>Created page. Translated first section from Catalan page and added pastecat.md documentation.</p>
<p><b>New page</b></p><div>== What is a plug-in? ==<br />
<br />
Cloudy is a Debian-based Linux distribution that provides users a simple and convenient web interface to manage different services that are to be used in a Community Network (in our case, Guifi).<br />
<br />
At the same time, Cloudy offers a set of tools that allow a user to add a service to the system without need for advanced knowledges on networking or computers in general. These services are automatically published to the Community Network, so that anybody using Cloudy can use this new service.<br />
<br />
'''Plug-ins''' are the modular pieces of code that allow adding and removing these services. Therefore, we understand thata plug-in is a program or a piece of software that a user can add to the Cloudy distribution and that can be managed in a simple way from the web interface provided by Cloudy.<br />
<br />
== Adding services to Cloudy ==<br />
<br />
=== A brief introduction ===<br />
<br />
<br />
= Service Addition in Cloudy =<br />
<br />
== A brief introduction ==<br />
<br />
This guide will walk you through the process of adding a new service to Cloudy.<br />
<br />
In order to be clear and provide examples, we are going to be integrating a very simple service showing snippets of code along the way.<br />
<br />
For the sake of simplicity, we will use [https://github.com/mvdan/pastecat Pastecat]. It is a good candidate because:<br />
<br />
* It's a standalone program<br />
* It only needs to be installed in one node (no federation/syncrhonization)<br />
* It's Built with Go, it's easy to distribute and deploy<br />
* It doesn't need a configuration file nor any kind of setup<br />
* It's very lightweight on resources<br />
<br />
== 1. Getting the binary ==<br />
<br />
The first thing we have to figure out is how to download and install the binary on Cloudy. Most software out there is already available as a package on Debian, but Pastecat isn't. If it were, it would be a matter of just running the command <code>apt-get install pastecat</code> from PHP. Therefore we'll have to get it from someplace else.<br />
<br />
One option is to fetch the source and build it ourselves. This often means, however, that Cloudy should include a lot of build tools and libraries. In the case of Go, that would mean having its toolchain installed, which isn't very practical.<br />
<br />
A better option when the Debian package isn't available is to download the binary from upstream trusted sources via HTTPS and, preferably, checking digests or using signatures. We can use Github's releases page for that. Both options leave us with an executable file that we should be able to run directly on Cloudy.<br />
<br />
In this particular case we are going to download the binaries from the git repository with the following command line:<br />
<br />
<pre>wget https://github.com/mvdan/pastecat/releases/download/v0.3.0/pastecat_linux_386</pre><br />
Note that in this case we are downloading a specific version for a Linux with a 386 architecture.<br />
<br />
Note that having the service as a Debian package has many advantages:<br />
<br />
* Updates are simple and need no extra work from Cloudy<br />
* The package is compiled and built by Debian in a trusted way<br />
* An init.d file is already provided<br />
* Debian packages often contain small patches and fixes<br />
<br />
== 2. Testing it out ==<br />
<br />
Before adding Pastecat as a Cloudy service, we can configure and start it ourselves directly (i.e. manually), to see if it works and how. This way we can better understand what configuration options or command line parameters are we will need to run it as a service, and also to manage it once it is running.<br />
<br />
== 3. Adding the controller ==<br />
<br />
In <code>web/plug/controllers</code> we have one PHP file per service, which we call &quot;the controller&quot;. This is the code that will run when we enter the services page on the Cloudy web interface.<br />
<br />
=== 3.1. Adding the index function ===<br />
<br />
We also want our service to be integrated in the Cloudy web structure. To do this, a few PHP scripts need to be created and added to our device. Altogether, and by the time being, we'll need to create a total of 2 scripts: <code>pastecat.PHP</code> and <code>pastecat.menu.PHP</code>. The first one is the controller itself, this is, the script that renders the page and has all the information such as buttons or redirections. The other one is what allows our service to show up in the upper menu bar of Cloudy's web interface.<br />
<br />
The menu code will look like this:<br />
<br />
<pre>&lt;?PHP<br />
//peerstreamer.menu.PHP<br />
addMenu('Pastecat','pastecat','Clommunity');</pre><br />
By now, we'll use a very simple PHP script in the controller:<br />
<br />
<pre>&lt;?PHP<br />
//pastecat<br />
$title=&quot;Pastecat&quot;;<br />
<br />
function index(){<br />
global $paspath,$title;<br />
global $staticFile;<br />
<br />
$page=hlc(t($title));<br />
$page .= hl(t(&quot;Minimalist pastebin engine written in Go&quot;),4);<br />
$page .= par(t(&quot;A simple and self-hosted pastebin service written in Go&quot;).' '.t(&quot;Can use a variety of storage backends&quot;).' '.t(&quot; Designed to optionally remove pastes after a certain period of time.&quot;).' '.(&quot;If using a persistent storage backend, pastes will be kept between runs.&quot;).' '.t(&quot;This software runs the&quot;).' '.&quot;&lt;a href='http://paste.cat'&gt;&quot;.t(&quot;paste.cat&quot;).&quot;&lt;/a&gt;&quot;. t(&quot; public service.&quot;));<br />
<br />
return(array('type' =&gt; 'render','page' =&gt; $page));<br />
}</pre><br />
In our Cloudy system, these files must be placed at <code>/var/local/cDistro/plug/</code> the first one at <code>menus</code> directory and the second at <code>controllers</code> directory. Once we've done this, we can go to our Cloudy system and access our new Pastecat.<br />
<br />
=== 3.2. Making the controller install the service ===<br />
<br />
As said before, this step is made much more easier if the service is packaged in Debian. Since Pastecat isn't, we'll have to do it manually. This usually involves a combination of <code>wget</code>, <code>mv</code> and <code>chmod</code>. It is generally a good idea to keep the service's files under <code>/opt/SERVICENAME</code>.<br />
<br />
In our particular case, the first thing we need to do is downloading the binary from the release. In order to do this we will make use of the mentioned <code>wget</code> command. Given a URL to a file, this command allows us to download this file in our system, and this is what we will do in our system (as mentioned before):<br />
<br />
<pre>wget https://github.com/mvdan/pastecat/releases/download/v0.3.0/pastecat_linux_386</pre><br />
Once we have the binary, we just need to move it to a directory where executable files use to be located. In our case, we will use the directory /opt/pastecat/. To move these files through our system we will use the command <code>mv</code>. However, first of all we need to create the directory where we will place our binary. To do this we use the <code>mkdir</code> command as is shown below:<br />
<br />
mkdir -p /opt/pastecat/<br />
<br />
Once we have our directory created, it is time to move the binary there:<br />
<br />
<pre>mv current_directory/pastecat_linux_386 /opt/pastecat/</pre><br />
where current_directory is the directory where we previously downloaded the binary. Since the binary name depends on the architecture, in order to simplfy the controller's code, we will change its name to something more simple:<br />
<br />
<pre>mv /opt/pastecat/pastecat_linux_386 /opt/pastecat/pastecat</pre><br />
Now our binary is called <code>pastecat</code> insted of <code>pastecat_linux_386</code><br />
<br />
These steps are the minimum requiered to install a service which is not provided in the Debian official repositories. However, to an end user, it would look like a nightmare to run these commands in a console connected through ssh to its device, so what we are going to do now, is create a bash script which will be called later from the web interface by clicking a button.<br />
<br />
This script is the first version of the pastecat controller. For the time being, We will just include a function to install pastecat in a device. Later we will include some other functions to add more facilities to our service.<br />
<br />
<pre>#!/bin/bash<br />
PCPATH=&quot;/opt/pastecat/&quot;<br />
<br />
doInstall() {<br />
if isInstall<br />
then<br />
echo &quot;Pastecat is already installed.&quot;<br />
return<br />
fi<br />
<br />
# Creating directory and switching<br />
mkdir -p $pcpath &amp;&amp; cd $pcpath<br />
<br />
# Getting file<br />
wget https://github.com/mvdan/pastecat/releases/download/v0.3.0/pastecat_linux_386<br />
<br />
# Changing name so controller can invoke it generically<br />
mv pastecat_linux_386 pastecat<br />
chmod +x pastecat<br />
<br />
cd -<br />
}<br />
<br />
isInstalled() {<br />
[ -d $pcpath ] &amp;&amp; return 0<br />
return 1<br />
}<br />
<br />
<br />
case $1 in<br />
&quot;install&quot;)<br />
shift<br />
doInstall $@<br />
;;<br />
esac</pre><br />
We can see how the lasts steps are done within the same function, allowing us to install the software in the device.<br />
<br />
=== 3.3 Making the controller use Pastecat ===<br />
<br />
== 3.3.1 Start the service ==<br />
<br />
The next thing we want is our software to be used through the web interface. In order to do this, we will include a new option to the main page of pastecat, and also integrate a new function to the controller script to manage the binary. We will add the button like this:<br />
<br />
<pre>$page .= addButton(array('label'=&gt;t('Create a Pastecat server'),'href'=&gt;$staticFile.'/pastecat/publish'));</pre><br />
after the <code>Pastecat is installed</code> message. The next thing will be implementing the function <code>publish</code> in the same PHP. This function is the responsible of calling the appropiate function in the controller and to announce our server usign the avahi technology. The difference with this function is that it requieres a form to introduce data, so in the end we will have a total of 2 functions: a get and a post:<br />
<br />
<pre>function publish_get() {<br />
global $pcpath,$title;<br />
global $staticFile;<br />
<br />
$page = hlc(t($title));<br />
$page .= hlc(t('Publish a pastecat server'),2);<br />
$page .= par(t(&quot;Write the port to publish your Pastecat service&quot;));<br />
$page .= createForm(array('class'=&gt;'form-horizontal'));<br />
$page .= addInput('description',t('Describe this server'));<br />
$page .= addSubmit(array('label'=&gt;t('Publish'),'class'=&gt;'btn btn-primary'));<br />
$page .= addButton(array('label'=&gt;t('Cancel'),'href'=&gt;$staticFile.'/peerstreamer'));<br />
<br />
return(array('type' =&gt; 'render','page' =&gt; $page));<br />
}<br />
<br />
function publish_post() {<br />
$port = $_POST['port'];<br />
$description = $_POST['description'];<br />
$ip = &quot;&quot;;<br />
<br />
$page = &quot;&lt;pre&gt;&quot;;<br />
$page .= _pcsource($description);<br />
$page .= &quot;&lt;/pre&gt;&quot;;<br />
<br />
return(array('type' =&gt; 'render','page' =&gt; $page));<br />
}</pre><br />
As we can see, in the <code>post</code> function we are invoking another function. The reason to do this is to write a more simple and modular code. In this function, we are finally calling the script:<br />
<br />
<pre>function _pcsource($port,$description) {<br />
global $pcpath,$pcprogram,$title,$pcutils,$avahi_type,$port;<br />
<br />
$page = &quot;&quot;;<br />
$device = getCommunityDev()['output'][0];<br />
$ipserver = getCommunityIP()['output'][0];<br />
<br />
if ($description == &quot;&quot;) $description = $type;<br />
<br />
$cmd = $pcutils.&quot; publish '$port' '$description';<br />
execute_program_detached($cmd);<br />
<br />
$page .= t($ipserver);<br />
$page .= par(t('Published this server.'));<br />
<br />
$page .= addButton(array('label'=&gt;t('Back'),'href'=&gt;$staticFile.'/pastecat'));<br />
<br />
return($page)<br />
}</pre><br />
The next thing to do will be create the function <code>publish</code> in the controller, so we will add a new function to the basic controller we had back at section '''3.2'''. We will add a new flag called publish, so the first executed part of the script will look like this:<br />
<br />
<pre>if [ $# -lt 1 ]<br />
then<br />
doHelp<br />
fi<br />
<br />
case $1 in<br />
&quot;install&quot;)<br />
shift<br />
doInstall $@<br />
;;<br />
&quot;publish&quot;)<br />
shift<br />
doServer $@<br />
;;<br />
esac</pre><br />
As we can see, when the script's first argument is <code>publish</code>, we shift the rest of arguments and call the function <code>doServer</code>. In this function, we must start the service with the requiered arguments, so the first thing we'll do is put the arguments into local variables. Once we do that the common thing would be to launche the Pastecat server, but since it might be called with root permissions (and this is bad) we must run it as a <code>nobody</code> user. The issue is that the <code>nobody</code> user has merely no permissions... and pastecat need some permissions to create folders and text files. In order to allow the <code>nobody</code> user to do that, first of all we will create a folder and grant permissions to almost everyone to it. We will use <code>chmod</code> again. Now, the user can create files and directories within this directory, so we can now run pastecat. Finally, we keep the pid in a variable in case we want to use it in later updates:<br />
<br />
<pre>doServer() {<br />
# Turning machine into a server<br />
<br />
local port=${1:-&quot;&quot;}<br />
local description=${2:-&quot;&quot;}<br />
local ip=${3:-&quot;0.0.0.0&quot;}<br />
<br />
# Creating directory with nobody permissions<br />
mkdir -p &quot;/var/local/pastecat&quot;<br />
chmod 777 &quot;/var/local/pastecat&quot; &amp;&amp; cd &quot;/var/local/pastecat&quot;<br />
<br />
# Running pastecat <br />
cmd='su '$PCUSER' -c &quot;{ '$PCPATH$PCPROG' -l :'$port' &gt; '$LOGFILE' 2&gt;&amp;1 &amp; }; echo \$!&quot;'<br />
pidpc=$(eval $cmd) # keeping PID for future needs...<br />
<br />
cd -<br />
<br />
# Using the PID, we could carry on process control so if the pastecat process die, we can also<br />
# stop the avahi process to avoid &quot;false connections&quot;<br />
<br />
return<br />
}</pre><br />
Note that we are using some global variables that were not defined before such as <code>PCUSER</code> and <code>LOGFILE</code>. By default, we set these variables like this:<br />
<br />
<pre>PCPATH=&quot;/opt/pastecat/&quot;<br />
PCPROG=&quot;pastecat&quot;<br />
LOGFILE=&quot;/dev/null&quot;<br />
PCUSER=&quot;nobody</pre><br />
== 3.3.2 Stop the service ==<br />
<br />
Sometimes, we may also want to stop out service, so we will provide a button to do so. The first thing would be creating the button, but if we think a little, we will figure out that before doing this, we need a way to know if our service is running. In addition, we also need a way to stop our service. Since we are running on Linux, we can easily achieve that by using the <code>kill</code> command. The thing is that to use this command, we need the Process ID (PID). Luckily for us, we already kept this number when we created the pastecat server with <code>pidpc=$(eval $cmd)</code>.<br />
<br />
Now that we have everything we need to kill our process, let's provide a way so the PHP can detect whether Pastecat is running or not. An easy and resulting way to do this is storing some useful data in a file and delete this file when pastecat is stopped. This way, we make sure that this file will only exists when Pastecat is running. This file will be created from the controller adding the following lines right below the sentence we mentioned in the previous paragraph:<br />
<br />
<pre># Writting server info to file<br />
info=&quot;$pidpc http://$ip:$port&quot; # Separator is space character<br />
echo $info &gt; $PCFILE</pre><br />
where <code>$PCFILE</code> is <code>/var/run/pc.info</code>. Note that the content of this file will be the PID and the complete direction of our Pastecat server.<br />
<br />
Now we have a way to know if our server is up or down, so we can add the &quot;stop&quot; button in the web interfae. We will modify a little bit the PHP script that we had before, just by addind anther advertisement indicating whether Pastecat is up or down, and 2 more buttons if it is running. So, in our index function, within the condition that checks if Pastecat is installed we will have the following code:<br />
<br />
<pre>$page .= &quot;&lt;div class='alert alert-success text-center'&gt;&quot;.t(&quot;Pastecat is installed&quot;).&quot;&lt;/div&gt;\n&quot;;<br />
if ( isRunning() ) {<br />
$page .= &quot;&lt;div class='alert alert-success text-center'&gt;&quot;.t(&quot;Pastecat is running&quot;).&quot;&lt;/div&gt;\n&quot;;<br />
$page .= addButton(array('label'=&gt;t('Go to server'),'href'=&gt;'http://'. getCommunityIP()['output'][0] .':'. $port));<br />
$page .= addButton(array('label'=&gt;t('Stop server'),'href'=&gt;$staticFile.'/pastecat/stop'));<br />
} else {<br />
$page .= &quot;&lt;div class='alert alert-error text-center'&gt;&quot;.t(&quot;Pastecat is not running&quot;).&quot;&lt;/div&gt;\n&quot;;<br />
}<br />
$page .= addButton(array('label'=&gt;t('Create a Pastecat server'),'href'=&gt;$staticFile.'/pastecat/publish'));</pre><br />
In this piece of code, we can appreciate 2 new features in our code. The first one is a check function called <code>isRunning()</code>. This function looks very similar to the function we used to check if Pastecat is installed:<br />
<br />
<pre>function isRunning() {<br />
// Returns whether pastecat is running or not<br />
global $pcfile;<br />
<br />
return(file_exists($pcfile)); <br />
}</pre><br />
It is a simple as it seems, it just checks if the file we created when starting the server still exists. The second thing we can notice in the new PHP code is the existance of a new function called <code>stop</code>. This function will invoke another function in the controller which will stop the pastecat:<br />
<br />
<pre>function stop() {<br />
// Stops Pastecat server<br />
global $pcpath,$pcprogram,$title,$pcutils,$avahi_type,$port;<br />
<br />
$page = &quot;&quot;;<br />
$cmd = $pcutils.&quot; stop &quot;;<br />
execute_program_detached($cmd);<br />
<br />
return(array('type'=&gt;'redirect','url'=&gt;$staticFile.'/pastecat'));<br />
}</pre><br />
In order to make the controller understand this order, we will modify the case and add the new function. In the <code>case</code> statement, we will add the following under the <code>install</code> option:<br />
<br />
<pre>&quot;stop&quot;)<br />
shift<br />
doStop $@<br />
;;</pre><br />
This calls the function <code>doStop</code> within the controller. This function will look like this:<br />
<br />
<pre>doStop() {<br />
# Stopping pastecat server<br />
pcpid=$(cat $PCFILE | cut -d' ' -f1)<br />
kill $pcpid<br />
<br />
# Removing info file<br />
rm $PCFILE<br />
}</pre><br />
This function just gets the pastecat's PID from the file we created before, kills the process and finally removes the file so the PHP scripts can know that pastecat is now down.<br />
<br />
Now we can create a pastecat instance server and stop it. However, there is still something missing: make the other users see our service. And this is why we are using avahi.<br />
<br />
== 4 Avahi service publishing ==<br />
<br />
On of the best things in Cloudy is the facility of publishing our service as a publication in the avahi network, allowing other users to know what we are offering and joining our service. To do this, we first need to add a few lines to the PHP controller, just after we've called the controller to start the pastecat instance. We will add the following lines:<br />
<br />
<pre>$description = str_replace(' ', '', $description);<br />
$temp = avahi_publish($avahi_type, $description, $port, &quot;&quot;);<br />
$page .= ptxt($temp);</pre><br />
So in the end our function will look like this:<br />
<br />
<pre>function _pcsource($port,$description) {<br />
global $pcpath,$pcprogram,$title,$pcutils,$avahi_type;<br />
<br />
$page = &quot;&quot;;<br />
$device = getCommunityDev()['output'][0];<br />
$ipserver = getCommunityIP()['output'][0];<br />
<br />
if ($description == &quot;&quot;) $description = $type;<br />
<br />
$cmd = $pcutils.&quot; publish '$port' '$description'&quot;;<br />
execute_program_detached($cmd);<br />
<br />
$page .= t($ipserver);<br />
$page .= par(t('Published this server.'));<br />
$description = str_replace(' ', '', $description);<br />
$temp = avahi_publish($avahi_type, $description, $port, &quot;&quot;);<br />
$page .= ptxt($temp);<br />
<br />
$page .= addButton(array('label'=&gt;t('Back'),'href'=&gt;$staticFile.'/pastecat'));<br />
<br />
return($page)<br />
}</pre><br />
With this simple step, we announced our service in the avahi network. However the work does not end here, there is still one more thing to do: create a button and program it so when clicked, it directly goes to our pastecat server.<br />
<br />
To do this there is a folder called <code>avahi</code> within the <code>plug</code> directory. The scripts that define the function carried on when the button is clicked are defined in different files within this directory, therefor we will create a new file called <code>pastecat.avahi.PHP</code> which will contain this:<br />
<br />
<pre>&lt;?PHP<br />
// plug/avahi/pastecat.avahi.PHP<br />
<br />
addAvahi('pastecat','fpcserver');<br />
<br />
function fpcserver($dates){<br />
global $staticFile;<br />
<br />
return (&quot;&lt;a class='btn' href='http://&quot; .$dates['ip'] .&quot;:&quot;. $dates['port'].&quot;'&gt;Go to server&lt;/a&gt; &quot;);<br />
}</pre><br />
This will create a button besides the avahi announcement line that will point to our server.<br />
<br />
Now that we have our service announced, we want it to dissappear when we stop the pastecat service. This last step is very simple yet important. It consist of a few lines in the PHP function called stop. Until now, this function just called the controller and stopped the pastecat, but now it will also stop the avahi publication and show a flash comment so the user knwo it worked:<br />
<br />
<pre>$temp = avahi_unpublish($avahi_type, $port);<br />
$flash = ptxt($temp);<br />
setFlash($flash);</pre><br />
These lines will be added just after the <code>execute_program_detached($cmd)</code> sentence in the stop function.<br />
<br />
<br />
<br />
<br />
<br />
<br />
== External links ==<br />
<br />
https://github.com/Clommunity/Doc/tree/master/plugins/pastecat<br />
<br />
<br />
<br />
[[Categoria:Cloudy]]<br />
[[ca:Cloudy_plug-ins]]<br />
[[es:Cloudy_plug-ins]]</div>Rogerpueyo