lxc.sh.html 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  1. <!DOCTYPE html>
  2. <html lang="en" data-content_root="../">
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <meta name="viewport" content="width=device-width, initial-scale=1">
  7. <title>utils/lxc.sh &#8212; SearXNG Documentation (2025.5.5+0315988f5)</title>
  8. <link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=6625fa76" />
  9. <link rel="stylesheet" type="text/css" href="../_static/searxng.css?v=52e4ff28" />
  10. <script src="../_static/documentation_options.js?v=6bec52eb"></script>
  11. <script src="../_static/doctools.js?v=9a2dae69"></script>
  12. <script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
  13. <script data-project="searxng" data-version="2025.5.5+0315988f5" src="../_static/describe_version.js?v=fa7f30d0"></script>
  14. <link rel="index" title="Index" href="../genindex.html" />
  15. <link rel="search" title="Search" href="../search.html" />
  16. <link rel="next" title="Source-Code" href="../src/index.html" />
  17. <link rel="prev" title="utils/searxng.sh" href="searxng.sh.html" />
  18. </head><body>
  19. <div class="related" role="navigation" aria-label="Related">
  20. <h3>Navigation</h3>
  21. <ul>
  22. <li class="right" style="margin-right: 10px">
  23. <a href="../genindex.html" title="General Index"
  24. accesskey="I">index</a></li>
  25. <li class="right" >
  26. <a href="../py-modindex.html" title="Python Module Index"
  27. >modules</a> |</li>
  28. <li class="right" >
  29. <a href="../src/index.html" title="Source-Code"
  30. accesskey="N">next</a> |</li>
  31. <li class="right" >
  32. <a href="searxng.sh.html" title="utils/searxng.sh"
  33. accesskey="P">previous</a> |</li>
  34. <li class="nav-item nav-item-0"><a href="../index.html">SearXNG Documentation (2025.5.5+0315988f5)</a> &#187;</li>
  35. <li class="nav-item nav-item-1"><a href="index.html" accesskey="U">DevOps tooling box</a> &#187;</li>
  36. <li class="nav-item nav-item-this"><a href=""><code class="docutils literal notranslate"><span class="pre">utils/lxc.sh</span></code></a></li>
  37. </ul>
  38. </div>
  39. <div class="document">
  40. <div class="documentwrapper">
  41. <div class="bodywrapper">
  42. <div class="body" role="main">
  43. <section id="utils-lxc-sh">
  44. <span id="lxc-sh"></span><h1><code class="docutils literal notranslate"><span class="pre">utils/lxc.sh</span></code><a class="headerlink" href="#utils-lxc-sh" title="Link to this heading">¶</a></h1>
  45. <p>With the use of <em>Linux Containers</em> (<a class="reference external" href="https://linuxcontainers.org/lxc/introduction/">LXC</a>) we can scale our tasks over a stack of
  46. containers, what we call the: <em>lxc suite</em>. The <a class="reference internal" href="#lxc-searxng-env"><span class="std std-ref">SearXNG suite config</span></a> is
  47. loaded by default, every time you start the <code class="docutils literal notranslate"><span class="pre">lxc.sh</span></code> script (<em>you do not need
  48. to care about</em>).</p>
  49. <aside class="sidebar">
  50. <p class="sidebar-title">further reading</p>
  51. <ul class="simple">
  52. <li><p><a class="reference external" href="https://snapcraft.io">snap</a>, <a class="reference external" href="https://snapcraft.io/lxd">snapcraft LXD</a></p></li>
  53. <li><p><a class="reference external" href="https://linuxcontainers.org/lxc/introduction/">LXC</a>, <a class="reference external" href="https://linuxcontainers.org/lxd/introduction/">LXD</a></p></li>
  54. <li><p><a class="reference external" href="https://uk.images.linuxcontainers.org/">LXC/LXD Image Server</a></p></li>
  55. <li><p><a class="reference external" href="https://github.com/lxc/lxd">LXD&#64;github</a></p></li>
  56. </ul>
  57. </aside>
  58. <nav class="contents local" id="contents">
  59. <ul class="simple">
  60. <li><p><a class="reference internal" href="#install-lxd" id="id5">Install LXD</a></p>
  61. <ul>
  62. <li><p><a class="reference internal" href="#internet-connectivity-docker" id="id6">Internet Connectivity &amp; Docker</a></p></li>
  63. </ul>
  64. </li>
  65. <li><p><a class="reference internal" href="#searxng-lxc-suite" id="id7">SearXNG LXC suite</a></p>
  66. <ul>
  67. <li><p><a class="reference internal" href="#running-commands" id="id8">Running commands</a></p></li>
  68. <li><p><a class="reference internal" href="#good-to-know" id="id9">Good to know</a></p></li>
  69. <li><p><a class="reference internal" href="#install-suite" id="id10">Install suite</a></p></li>
  70. <li><p><a class="reference internal" href="#clean-up" id="id11">Clean up</a></p></li>
  71. </ul>
  72. </li>
  73. <li><p><a class="reference internal" href="#setup-searxng-buildhost" id="id12">Setup SearXNG buildhost</a></p></li>
  74. <li><p><a class="reference internal" href="#command-help" id="id13">Command Help</a></p></li>
  75. <li><p><a class="reference internal" href="#searxng-suite-config" id="id14">SearXNG suite config</a></p></li>
  76. </ul>
  77. </nav>
  78. <section id="install-lxd">
  79. <span id="lxd-install"></span><h2><a class="toc-backref" href="#id5" role="doc-backlink">Install LXD</a><a class="headerlink" href="#install-lxd" title="Link to this heading">¶</a></h2>
  80. <p>Before you can start with containers, you need to install and initiate <a class="reference external" href="https://linuxcontainers.org/lxd/introduction/">LXD</a>
  81. once:</p>
  82. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ snap install lxd
  83. $ lxd init --auto
  84. </pre></div>
  85. </div>
  86. <p>To make use of the containers from the <em>SearXNG suite</em>, you have to build the
  87. <a class="reference internal" href="#lxc-sh-help"><span class="std std-ref">LXC suite containers</span></a> initial. But be warned, <strong>this might
  88. take some time</strong>:</p>
  89. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ sudo -H ./utils/lxc.sh build
  90. </pre></div>
  91. </div>
  92. <aside class="sidebar">
  93. <p class="sidebar-title">hint</p>
  94. <p>If you have issues with the internet connectivity of your containers read
  95. section <a class="reference internal" href="#internet-connectivity-docker"><span class="std std-ref">Internet Connectivity &amp; Docker</span></a>.</p>
  96. </aside>
  97. <p>A cup of coffee later, your LXC suite is build up and you can run whatever task
  98. you want / in a selected or even in all <a class="reference internal" href="#lxc-sh-help"><span class="std std-ref">LXC suite containers</span></a>.</p>
  99. <section id="internet-connectivity-docker">
  100. <span id="id1"></span><h3><a class="toc-backref" href="#id6" role="doc-backlink">Internet Connectivity &amp; Docker</a><a class="headerlink" href="#internet-connectivity-docker" title="Link to this heading">¶</a></h3>
  101. <aside class="sidebar">
  102. <p class="sidebar-title">further read</p>
  103. <ul class="simple">
  104. <li><p><a class="reference external" href="https://github.com/docker/for-linux/issues/103">Docker blocking network of existing LXC containers</a></p></li>
  105. <li><p><a class="reference external" href="https://fralef.me/docker-and-iptables.html">Docker and IPtables (fralef.me)</a></p></li>
  106. <li><p><a class="reference external" href="https://docs.docker.com/network/iptables/#docker-on-a-router/">Docker and iptables (docker.com)</a></p></li>
  107. </ul>
  108. </aside>
  109. <p>There is a conflict in the <code class="docutils literal notranslate"><span class="pre">iptables</span></code> setup of Docker &amp; LXC. If you have
  110. docker installed, you may find that the internet connectivity of your LXD
  111. containers no longer work.</p>
  112. <p>Whenever docker is started (reboot) it sets the iptables policy for the
  113. <code class="docutils literal notranslate"><span class="pre">FORWARD</span></code> chain to <code class="docutils literal notranslate"><span class="pre">DROP</span></code> <a class="reference external" href="https://docs.docker.com/network/iptables/#docker-on-a-router">[ref]</a>:</p>
  114. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ sudo -H iptables-save | grep FORWARD
  115. :FORWARD ACCEPT [7048:7851230]
  116. :FORWARD DROP [7048:7851230]
  117. </pre></div>
  118. </div>
  119. <p>A handy solution of this problem might be to reset the policy for the
  120. <code class="docutils literal notranslate"><span class="pre">FORWARD</span></code> chain after the network has been initialized. For this create a
  121. file in the <code class="docutils literal notranslate"><span class="pre">if-up</span></code> section of the network (<code class="docutils literal notranslate"><span class="pre">/etc/network/if-up.d/iptable</span></code>)
  122. and insert the following lines:</p>
  123. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="ch">#!/bin/sh</span>
  124. <span class="n">iptables</span> <span class="o">-</span><span class="n">F</span> <span class="n">FORWARD</span>
  125. <span class="n">iptables</span> <span class="o">-</span><span class="n">P</span> <span class="n">FORWARD</span> <span class="n">ACCEPT</span>
  126. </pre></div>
  127. </div>
  128. <p>Don’t forget to set the execution bit:</p>
  129. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">chmod</span> <span class="n">ugo</span><span class="o">+</span><span class="n">x</span> <span class="o">/</span><span class="n">etc</span><span class="o">/</span><span class="n">network</span><span class="o">/</span><span class="k">if</span><span class="o">-</span><span class="n">up</span><span class="o">.</span><span class="n">d</span><span class="o">/</span><span class="n">iptable</span>
  130. </pre></div>
  131. </div>
  132. <p>Reboot your system and check the iptables rules:</p>
  133. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ sudo -H iptables-save | grep FORWARD
  134. :FORWARD ACCEPT [7048:7851230]
  135. :FORWARD ACCEPT [7048:7851230]
  136. </pre></div>
  137. </div>
  138. </section>
  139. </section>
  140. <section id="searxng-lxc-suite">
  141. <span id="id2"></span><h2><a class="toc-backref" href="#id7" role="doc-backlink">SearXNG LXC suite</a><a class="headerlink" href="#searxng-lxc-suite" title="Link to this heading">¶</a></h2>
  142. <p>The intention of the <em>SearXNG LXC suite</em> is to build up a suite of containers
  143. for development tasks or <a class="reference internal" href="#setup-searxng-buildhost"><span class="std std-ref">buildhosts</span></a> with a very
  144. small set of simple commands. At the end of the <code class="docutils literal notranslate"><span class="pre">--help</span></code> output the SearXNG
  145. suite from the <a class="reference internal" href="#lxc-searxng-env"><span class="std std-ref">SearXNG suite config</span></a> is introduced:</p>
  146. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ sudo -H ./utils/lxc.sh --help
  147. ...
  148. LXC suite: searxng
  149. Suite includes installation of SearXNG
  150. images: ubu2004 ubu2204 fedora35 archlinux
  151. containers: searxng-ubu2004 searxng-ubu2204 searxng-fedora35 searxng-archlinux
  152. </pre></div>
  153. </div>
  154. <p>As shown above there are images and containers build up on this images. To show
  155. more info about the containers in the <em>SearXNG LXC suite</em> call <code class="docutils literal notranslate"><span class="pre">show</span> <span class="pre">suite</span></code>.
  156. If this is the first time you make use of the SearXNG LXC suite, no containers
  157. are installed and the output is:</p>
  158. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ sudo -H ./utils/lxc.sh show suite
  159. LXC suite (searxng-*)
  160. =====================
  161. +------+-------+------+------+------+-----------+
  162. | NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
  163. +------+-------+------+------+------+-----------+
  164. WARN: container searxng-ubu2004 does not yet exists
  165. WARN: container searxng-ubu2204 does not yet exists
  166. WARN: container searxng-fedora35 does not yet exists
  167. WARN: container searxng-archlinux does not yet exists
  168. </pre></div>
  169. </div>
  170. <p>If you do not want to run a command or a build in all containers, <strong>you can
  171. build just one</strong>. Here by example in the container that is build upon the
  172. <em>archlinux</em> image:</p>
  173. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ sudo -H ./utils/lxc.sh build searxng-archlinux
  174. $ sudo -H ./utils/lxc.sh cmd searxng-archlinux pwd
  175. </pre></div>
  176. </div>
  177. <p>Otherwise, to apply a command to all containers you can use:</p>
  178. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ sudo -H ./utils/lxc.sh build
  179. $ sudo -H ./utils/lxc.sh cmd -- ls -la .
  180. </pre></div>
  181. </div>
  182. <section id="running-commands">
  183. <h3><a class="toc-backref" href="#id8" role="doc-backlink">Running commands</a><a class="headerlink" href="#running-commands" title="Link to this heading">¶</a></h3>
  184. <p><strong>Inside containers, you can run scripts</strong> from the <a class="reference internal" href="index.html#toolboxing"><span class="std std-ref">DevOps tooling box</span></a> or run
  185. what ever command you need. By example, to start a bash use:</p>
  186. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ sudo -H ./utils/lxc.sh cmd searxng-archlinux bash
  187. INFO: [searxng-archlinux] bash
  188. [root@searxng-archlinux SearXNG]#
  189. </pre></div>
  190. </div>
  191. </section>
  192. <section id="good-to-know">
  193. <span id="id3"></span><h3><a class="toc-backref" href="#id9" role="doc-backlink">Good to know</a><a class="headerlink" href="#good-to-know" title="Link to this heading">¶</a></h3>
  194. <p>Each container shares the root folder of the repository and the command
  195. <code class="docutils literal notranslate"><span class="pre">utils/lxc.sh</span> <span class="pre">cmd</span></code> <strong>handle relative path names transparent</strong>:</p>
  196. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ pwd
  197. /share/SearXNG
  198. $ sudo -H ./utils/lxc.sh cmd searxng-archlinux pwd
  199. INFO: [searxng-archlinux] pwd
  200. /share/SearXNG
  201. </pre></div>
  202. </div>
  203. <p>The path <code class="docutils literal notranslate"><span class="pre">/share/SearXNG</span></code> will be different on your HOST system. The commands
  204. in the container are executed by the <code class="docutils literal notranslate"><span class="pre">root</span></code> inside of the container. Compare
  205. output of:</p>
  206. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ ls -li Makefile
  207. 47712402 -rw-rw-r-- 1 markus markus 2923 Apr 19 13:52 Makefile
  208. $ sudo -H ./utils/lxc.sh cmd searxng-archlinux ls -li Makefile
  209. INFO: [searxng-archlinux] ls -li Makefile
  210. 47712402 -rw-rw-r-- 1 root root 2923 Apr 19 11:52 Makefile
  211. ...
  212. </pre></div>
  213. </div>
  214. <p>Since the path <code class="docutils literal notranslate"><span class="pre">/share/SearXNG</span></code> of the HOST system is wrapped into the
  215. container under the same name, the shown <code class="docutils literal notranslate"><span class="pre">Makefile</span></code> (inode <code class="docutils literal notranslate"><span class="pre">47712402</span></code>) in
  216. the output is always the identical <code class="docutils literal notranslate"><span class="pre">/share/SearXNG/Makefile</span></code> from the HOST
  217. system. In the example shown above the owner of the path in the container is
  218. the <code class="docutils literal notranslate"><span class="pre">root</span></code> user of the container (and the timezone in the container is
  219. different to HOST system).</p>
  220. </section>
  221. <section id="install-suite">
  222. <span id="lxc-sh-install-suite"></span><h3><a class="toc-backref" href="#id10" role="doc-backlink">Install suite</a><a class="headerlink" href="#install-suite" title="Link to this heading">¶</a></h3>
  223. <aside class="sidebar">
  224. <p class="sidebar-title">further read</p>
  225. <ul class="simple">
  226. <li><p><a class="reference internal" href="../dev/lxcdev.html#working-in-containers"><span class="std std-ref">In containers, work as usual</span></a></p></li>
  227. <li><p><a class="reference internal" href="index.html#force-timeout"><span class="std std-ref">FORCE_TIMEOUT</span></a></p></li>
  228. </ul>
  229. </aside>
  230. <p>To install the complete <a class="reference internal" href="#lxc-searxng-env"><span class="std std-ref">SearXNG suite</span></a> into <strong>all</strong> <a class="reference external" href="https://linuxcontainers.org/lxc/introduction/">LXC</a>
  231. containers leave the container argument empty and run:</p>
  232. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ sudo -H ./utils/lxc.sh build
  233. $ sudo -H ./utils/lxc.sh install suite
  234. </pre></div>
  235. </div>
  236. <p>To <em>build &amp; install</em> suite only in one container you can use by example:</p>
  237. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ sudo -H ./utils/lxc.sh build searxng-archlinux
  238. $ sudo -H ./utils/lxc.sh install suite searxng-archlinux
  239. </pre></div>
  240. </div>
  241. <p>The command above installs a SearXNG suite (see <a class="reference internal" href="../admin/installation-scripts.html#installation-scripts"><span class="std std-ref">Installation Script</span></a>).
  242. To <a class="reference internal" href="../admin/installation-nginx.html#installation-nginx"><span class="std std-ref">install a nginx</span></a> reverse proxy (or alternatively
  243. use <a class="reference internal" href="../admin/installation-apache.html#installation-apache"><span class="std std-ref">apache</span></a>):</p>
  244. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ sudo -H ./utils/lxc.sh cmd -- FORCE_TIMEOUT=0 ./utils/searxng.sh install nginx
  245. </pre></div>
  246. </div>
  247. <p>Same operation just in one container of the suite:</p>
  248. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ sudo -H ./utils/lxc.sh cmd searxng-archlinux FORCE_TIMEOUT=0 ./utils/searxng.sh install nginx
  249. </pre></div>
  250. </div>
  251. <p>The <a class="reference internal" href="index.html#force-timeout"><span class="std std-ref">FORCE_TIMEOUT</span></a> environment is set to zero to run the
  252. script without user interaction.</p>
  253. <p>To get the IP (URL) of the SearXNG service in the containers use <code class="docutils literal notranslate"><span class="pre">show</span> <span class="pre">suite</span></code>
  254. command. To test instances from containers just open the URLs in your
  255. WEB-Browser:</p>
  256. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ sudo ./utils/lxc.sh show suite | grep SEARXNG_URL
  257. [searxng-ubu2110] SEARXNG_URL : http://n.n.n.170/searxng
  258. [searxng-ubu2004] SEARXNG_URL : http://n.n.n.160/searxng
  259. [searxnggfedora35] SEARXNG_URL : http://n.n.n.150/searxng
  260. [searxng-archlinux] SEARXNG_URL : http://n.n.n.140/searxng
  261. </pre></div>
  262. </div>
  263. </section>
  264. <section id="clean-up">
  265. <h3><a class="toc-backref" href="#id11" role="doc-backlink">Clean up</a><a class="headerlink" href="#clean-up" title="Link to this heading">¶</a></h3>
  266. <p>If there comes the time you want to <strong>get rid off all</strong> the containers and
  267. <strong>clean up local images</strong> just type:</p>
  268. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ sudo -H ./utils/lxc.sh remove
  269. $ sudo -H ./utils/lxc.sh remove images
  270. </pre></div>
  271. </div>
  272. </section>
  273. </section>
  274. <section id="setup-searxng-buildhost">
  275. <span id="id4"></span><h2><a class="toc-backref" href="#id12" role="doc-backlink">Setup SearXNG buildhost</a><a class="headerlink" href="#setup-searxng-buildhost" title="Link to this heading">¶</a></h2>
  276. <p>You can <strong>install the SearXNG buildhost environment</strong> into one or all containers.
  277. The installation procedure to set up a <a class="reference internal" href="../admin/buildhosts.html#buildhosts"><span class="std std-ref">build host</span></a> takes its
  278. time. Installation in all containers will take more time (time for another cup
  279. of coffee).</p>
  280. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="o">-</span><span class="n">H</span> <span class="o">./</span><span class="n">utils</span><span class="o">/</span><span class="n">lxc</span><span class="o">.</span><span class="n">sh</span> <span class="n">cmd</span> <span class="o">--</span> <span class="o">./</span><span class="n">utils</span><span class="o">/</span><span class="n">searxng</span><span class="o">.</span><span class="n">sh</span> <span class="n">install</span> <span class="n">buildhost</span>
  281. </pre></div>
  282. </div>
  283. <p>To build (live) documentation inside a <a class="reference external" href="https://www.archlinux.org/">archlinux</a> container:</p>
  284. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="o">-</span><span class="n">H</span> <span class="o">./</span><span class="n">utils</span><span class="o">/</span><span class="n">lxc</span><span class="o">.</span><span class="n">sh</span> <span class="n">cmd</span> <span class="n">searxng</span><span class="o">-</span><span class="n">archlinux</span> <span class="n">make</span> <span class="n">docs</span><span class="o">.</span><span class="n">clean</span> <span class="n">docs</span><span class="o">.</span><span class="n">live</span>
  285. <span class="o">...</span>
  286. <span class="p">[</span><span class="n">I</span> <span class="mi">200331</span> <span class="mi">15</span><span class="p">:</span><span class="mi">00</span><span class="p">:</span><span class="mi">42</span> <span class="n">server</span><span class="p">:</span><span class="mi">296</span><span class="p">]</span> <span class="n">Serving</span> <span class="n">on</span> <span class="n">http</span><span class="p">:</span><span class="o">//</span><span class="mf">0.0.0.0</span><span class="p">:</span><span class="mi">8080</span>
  287. </pre></div>
  288. </div>
  289. <p>To get IP of the container and the port number <em>live docs</em> is listening:</p>
  290. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ sudo ./utils/lxc.sh show suite | grep docs.live
  291. ...
  292. [searxng-archlinux] INFO: (eth0) docs.live: http://n.n.n.140:8080/
  293. </pre></div>
  294. </div>
  295. </section>
  296. <section id="command-help">
  297. <span id="lxc-sh-help"></span><h2><a class="toc-backref" href="#id13" role="doc-backlink">Command Help</a><a class="headerlink" href="#command-help" title="Link to this heading">¶</a></h2>
  298. <p>The <code class="docutils literal notranslate"><span class="pre">--help</span></code> output of the script is largely self-explanatory:</p>
  299. <div class="highlight-text notranslate"><div class="highlight"><pre><span></span>usage::
  300. lxc.sh build [containers|&lt;name&gt;]
  301. lxc.sh copy [images]
  302. lxc.sh remove [containers|&lt;name&gt;|images]
  303. lxc.sh [start|stop] [containers|&lt;name&gt;]
  304. lxc.sh show [images|suite|info|config [&lt;name&gt;]]
  305. lxc.sh cmd [--|&lt;name&gt;] &#39;...&#39;
  306. lxc.sh install [suite|base [&lt;name&gt;]]
  307. build
  308. :containers: build, launch all containers and &#39;install base&#39; packages
  309. :&lt;name&gt;: build, launch container &lt;name&gt; and &#39;install base&#39; packages
  310. copy:
  311. :images: copy remote images of the suite into local storage
  312. remove
  313. :containers: delete all &#39;containers&#39; or only &lt;container-name&gt;
  314. :images: delete local images of the suite
  315. start/stop
  316. :containers: start/stop all &#39;containers&#39; from the suite
  317. :&lt;name&gt;: start/stop container &lt;name&gt; from suite
  318. show
  319. :info: show info of all (or &lt;name&gt;) containers from LXC suite
  320. :config: show config of all (or &lt;name&gt;) containers from the LXC suite
  321. :suite: show services of all (or &lt;name&gt;) containers from the LXC suite
  322. :images: show information of local images
  323. cmd
  324. use single quotes to evaluate in container&#39;s bash, e.g.: &#39;echo $(hostname)&#39;
  325. -- run command &#39;...&#39; in all containers of the LXC suite
  326. :&lt;name&gt;: run command &#39;...&#39; in container &lt;name&gt;
  327. install
  328. :base: prepare LXC; install basic packages
  329. :suite: install LXC searxng suite into all (or &lt;name&gt;) containers
  330. LXC suite: searxng
  331. Suite includes installation of SearXNG
  332. images: ubu2004 ubu2204 fedora35 archlinux
  333. containers: searxng-ubu2004 searxng-ubu2204 searxng-fedora35 searxng-archlinux
  334. </pre></div>
  335. </div>
  336. </section>
  337. <section id="searxng-suite-config">
  338. <span id="lxc-searxng-env"></span><h2><a class="toc-backref" href="#id14" role="doc-backlink">SearXNG suite config</a><a class="headerlink" href="#searxng-suite-config" title="Link to this heading">¶</a></h2>
  339. <p>The SearXNG suite is defined in the file <a class="extlink-origin reference external" href="https://github.com/searxng/searxng/blob/master/utils/lxc-searxng.env">git://utils/lxc-searxng.env</a>:</p>
  340. <div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="c1"># -*- coding: utf-8; mode: sh indent-tabs-mode: nil -*-</span>
  341. <span class="c1"># SPDX-License-Identifier: AGPL-3.0-or-later</span>
  342. <span class="c1"># shellcheck shell=bash</span>
  343. <span class="c1"># This file is a setup of a LXC suite. It is sourced from different context, do</span>
  344. <span class="c1"># not manipulate the environment directly, implement functions and manipulate</span>
  345. <span class="c1"># environment only in subshells.</span>
  346. lxc_set_suite_env<span class="o">()</span><span class="w"> </span><span class="o">{</span>
  347. <span class="w"> </span><span class="nb">export</span><span class="w"> </span><span class="nv">LXC_SUITE_NAME</span><span class="o">=</span><span class="s2">&quot;searxng&quot;</span>
  348. <span class="w"> </span><span class="c1"># name of https://images.linuxcontainers.org</span>
  349. <span class="w"> </span><span class="nb">export</span><span class="w"> </span><span class="nv">LINUXCONTAINERS_ORG_NAME</span><span class="o">=</span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">LINUXCONTAINERS_ORG_NAME</span><span class="k">:-</span><span class="nv">images</span><span class="si">}</span><span class="s2">&quot;</span>
  350. <span class="w"> </span><span class="nb">export</span><span class="w"> </span><span class="nv">LXC_HOST_PREFIX</span><span class="o">=</span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">LXC_SUITE_NAME</span><span class="k">:-</span><span class="nv">searx</span><span class="si">}</span><span class="s2">&quot;</span>
  351. <span class="w"> </span><span class="nb">export</span><span class="w"> </span><span class="nv">LXC_SUITE</span><span class="o">=(</span>
  352. <span class="w"> </span><span class="c1"># end of standard support see https://wiki.ubuntu.com/Releases</span>
  353. <span class="w"> </span><span class="s2">&quot;</span><span class="nv">$LINUXCONTAINERS_ORG_NAME</span><span class="s2">:ubuntu/20.04&quot;</span><span class="w"> </span><span class="s2">&quot;ubu2004&quot;</span><span class="w"> </span><span class="c1"># LTS EOSS April 2025</span>
  354. <span class="w"> </span><span class="s2">&quot;</span><span class="nv">$LINUXCONTAINERS_ORG_NAME</span><span class="s2">:ubuntu/22.04&quot;</span><span class="w"> </span><span class="s2">&quot;ubu2204&quot;</span><span class="w"> </span><span class="c1"># LTS EOSS April 2027</span>
  355. <span class="w"> </span><span class="c1"># EOL see https://fedoraproject.org/wiki/Releases</span>
  356. <span class="w"> </span><span class="s2">&quot;</span><span class="nv">$LINUXCONTAINERS_ORG_NAME</span><span class="s2">:fedora/35&quot;</span><span class="w"> </span><span class="s2">&quot;fedora35&quot;</span>
  357. <span class="w"> </span><span class="c1"># rolling releases see https://www.archlinux.org/releng/releases/</span>
  358. <span class="w"> </span><span class="s2">&quot;</span><span class="nv">$LINUXCONTAINERS_ORG_NAME</span><span class="s2">:archlinux&quot;</span><span class="w"> </span><span class="s2">&quot;archlinux&quot;</span>
  359. <span class="w"> </span><span class="o">)</span>
  360. <span class="o">}</span>
  361. lxc_suite_install_info<span class="o">()</span><span class="w"> </span><span class="o">{</span>
  362. <span class="w"> </span><span class="o">(</span>
  363. <span class="w"> </span>lxc_set_suite_env
  364. <span class="w"> </span>cat<span class="w"> </span><span class="s">&lt;&lt;EOF</span>
  365. <span class="s">LXC suite: ${LXC_SUITE_NAME}</span>
  366. <span class="s"> Suite includes installation of SearXNG</span>
  367. <span class="s"> images: ${LOCAL_IMAGES[*]}</span>
  368. <span class="s"> containers: ${CONTAINERS[*]}</span>
  369. <span class="s">EOF</span>
  370. <span class="w"> </span><span class="o">)</span>
  371. <span class="o">}</span>
  372. lxc_suite_install<span class="o">()</span><span class="w"> </span><span class="o">{</span>
  373. <span class="w"> </span><span class="o">(</span>
  374. <span class="w"> </span>lxc_set_suite_env
  375. <span class="w"> </span><span class="nv">FORCE_TIMEOUT</span><span class="o">=</span><span class="m">0</span><span class="w"> </span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">LXC_REPO_ROOT</span><span class="si">}</span><span class="s2">/utils/searxng.sh&quot;</span><span class="w"> </span>install<span class="w"> </span>all
  376. <span class="w"> </span>rst_title<span class="w"> </span><span class="s2">&quot;Suite installation finished (</span><span class="k">$(</span>hostname<span class="k">)</span><span class="s2">)&quot;</span><span class="w"> </span>part
  377. <span class="w"> </span><span class="k">if</span><span class="w"> </span>ask_yn<span class="w"> </span><span class="s2">&quot;Developer install? (wraps source from HOST into the running instance)&quot;</span><span class="w"> </span>Yn<span class="p">;</span><span class="w"> </span><span class="k">then</span>
  378. <span class="w"> </span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">LXC_REPO_ROOT</span><span class="si">}</span><span class="s2">/utils/searxng.sh&quot;</span><span class="w"> </span>searxng.install.link_src<span class="w"> </span><span class="s2">&quot;</span><span class="k">$(</span><span class="nb">pwd</span><span class="k">)</span><span class="s2">&quot;</span>
  379. <span class="w"> </span><span class="k">fi</span>
  380. <span class="w"> </span>lxc_suite_info
  381. <span class="w"> </span><span class="nb">echo</span>
  382. <span class="w"> </span><span class="o">)</span>
  383. <span class="o">}</span>
  384. lxc_suite_info<span class="o">()</span><span class="w"> </span><span class="o">{</span>
  385. <span class="w"> </span><span class="o">(</span>
  386. <span class="w"> </span>lxc_set_suite_env
  387. <span class="w"> </span><span class="k">for</span><span class="w"> </span>ip<span class="w"> </span><span class="k">in</span><span class="w"> </span><span class="k">$(</span>global_IPs<span class="k">)</span><span class="w"> </span><span class="p">;</span><span class="w"> </span><span class="k">do</span>
  388. <span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="o">[[</span><span class="w"> </span><span class="nv">$ip</span><span class="w"> </span><span class="o">=</span>~<span class="w"> </span>.*:.*<span class="w"> </span><span class="o">]]</span><span class="p">;</span><span class="w"> </span><span class="k">then</span>
  389. <span class="w"> </span>info_msg<span class="w"> </span><span class="s2">&quot;(</span><span class="si">${</span><span class="nv">ip</span><span class="p">%|*</span><span class="si">}</span><span class="s2">) IPv6: http://[</span><span class="si">${</span><span class="nv">ip</span><span class="p">#*|</span><span class="si">}</span><span class="s2">]&quot;</span>
  390. <span class="w"> </span><span class="k">else</span>
  391. <span class="w"> </span><span class="c1"># IPv4:</span>
  392. <span class="w"> </span><span class="c1"># shellcheck disable=SC2034,SC2031</span>
  393. <span class="w"> </span>info_msg<span class="w"> </span><span class="s2">&quot;(</span><span class="si">${</span><span class="nv">ip</span><span class="p">%|*</span><span class="si">}</span><span class="s2">) docs-live: http://</span><span class="si">${</span><span class="nv">ip</span><span class="p">#*|</span><span class="si">}</span><span class="s2">:8080/&quot;</span>
  394. <span class="w"> </span><span class="k">fi</span>
  395. <span class="w"> </span><span class="k">done</span>
  396. <span class="w"> </span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">LXC_REPO_ROOT</span><span class="si">}</span><span class="s2">/utils/searxng.sh&quot;</span><span class="w"> </span>searxng.instance.env
  397. <span class="w"> </span><span class="o">)</span>
  398. <span class="o">}</span>
  399. </pre></div>
  400. </div>
  401. </section>
  402. </section>
  403. <div class="clearer"></div>
  404. </div>
  405. </div>
  406. </div>
  407. <span id="sidebar-top"></span>
  408. <div class="sphinxsidebar" role="navigation" aria-label="Main">
  409. <div class="sphinxsidebarwrapper">
  410. <p class="logo"><a href="../index.html">
  411. <img class="logo" src="../_static/searxng-wordmark.svg" alt="Logo of SearXNG"/>
  412. </a></p>
  413. <h3><a href="../index.html">Table of Contents</a></h3>
  414. <ul class="current">
  415. <li class="toctree-l1"><a class="reference internal" href="../user/index.html">User information</a></li>
  416. <li class="toctree-l1"><a class="reference internal" href="../own-instance.html">Why use a private instance?</a></li>
  417. <li class="toctree-l1"><a class="reference internal" href="../admin/index.html">Administrator documentation</a></li>
  418. <li class="toctree-l1"><a class="reference internal" href="../dev/index.html">Developer documentation</a></li>
  419. <li class="toctree-l1 current"><a class="reference internal" href="index.html">DevOps tooling box</a><ul class="current">
  420. <li class="toctree-l2"><a class="reference internal" href="searxng.sh.html"><code class="docutils literal notranslate"><span class="pre">utils/searxng.sh</span></code></a></li>
  421. <li class="toctree-l2 current"><a class="current reference internal" href="#"><code class="docutils literal notranslate"><span class="pre">utils/lxc.sh</span></code></a><ul>
  422. <li class="toctree-l3"><a class="reference internal" href="#install-lxd">Install LXD</a><ul>
  423. <li class="toctree-l4"><a class="reference internal" href="#internet-connectivity-docker">Internet Connectivity &amp; Docker</a></li>
  424. </ul>
  425. </li>
  426. <li class="toctree-l3"><a class="reference internal" href="#searxng-lxc-suite">SearXNG LXC suite</a><ul>
  427. <li class="toctree-l4"><a class="reference internal" href="#running-commands">Running commands</a></li>
  428. <li class="toctree-l4"><a class="reference internal" href="#good-to-know">Good to know</a></li>
  429. <li class="toctree-l4"><a class="reference internal" href="#install-suite">Install suite</a></li>
  430. <li class="toctree-l4"><a class="reference internal" href="#clean-up">Clean up</a></li>
  431. </ul>
  432. </li>
  433. <li class="toctree-l3"><a class="reference internal" href="#setup-searxng-buildhost">Setup SearXNG buildhost</a></li>
  434. <li class="toctree-l3"><a class="reference internal" href="#command-help">Command Help</a></li>
  435. <li class="toctree-l3"><a class="reference internal" href="#searxng-suite-config">SearXNG suite config</a></li>
  436. </ul>
  437. </li>
  438. <li class="toctree-l2"><a class="reference internal" href="index.html#common-command-environments">Common command environments</a></li>
  439. </ul>
  440. </li>
  441. <li class="toctree-l1"><a class="reference internal" href="../src/index.html">Source-Code</a></li>
  442. </ul>
  443. <h3>Project Links</h3>
  444. <ul>
  445. <li><a href="https://github.com/searxng/searxng/tree/master">Source</a>
  446. <li><a href="https://github.com/searxng/searxng/wiki">Wiki</a>
  447. <li><a href="https://searx.space">Public instances</a>
  448. <li><a href="https://github.com/searxng/searxng/issues">Issue Tracker</a>
  449. </ul><h3>Navigation</h3>
  450. <ul>
  451. <li><a href="../index.html">Overview</a>
  452. <ul>
  453. <li><a href="index.html">DevOps tooling box</a>
  454. <ul>
  455. <li>Previous: <a href="searxng.sh.html" title="previous chapter"><code class="docutils literal notranslate"><span class="pre">utils/searxng.sh</span></code></a>
  456. <li>Next: <a href="../src/index.html" title="next chapter">Source-Code</a></ul>
  457. </li>
  458. </ul>
  459. </li>
  460. </ul>
  461. <search id="searchbox" style="display: none" role="search">
  462. <h3 id="searchlabel">Quick search</h3>
  463. <div class="searchformwrapper">
  464. <form class="search" action="../search.html" method="get">
  465. <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
  466. <input type="submit" value="Go" />
  467. </form>
  468. </div>
  469. </search>
  470. <script>document.getElementById('searchbox').style.display = "block"</script>
  471. <div role="note" aria-label="source link">
  472. <h3>This Page</h3>
  473. <ul class="this-page-menu">
  474. <li><a href="../_sources/utils/lxc.sh.rst.txt"
  475. rel="nofollow">Show Source</a></li>
  476. </ul>
  477. </div>
  478. </div>
  479. </div>
  480. <div class="clearer"></div>
  481. </div>
  482. <div class="footer" role="contentinfo">
  483. &#169; Copyright SearXNG team.
  484. </div>
  485. </body>
  486. </html>