summaryrefslogtreecommitdiff
path: root/utils/lxc.sh.html
blob: 4f1d83d4e1a1cdedef1e07ce8fdf2929b9ee4a07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
<!DOCTYPE html>

<html lang="en" data-content_root="../">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>utils/lxc.sh &#8212; SearXNG Documentation (2025.1.6+6dab7fe78)</title>
    <link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=4f649999" />
    <link rel="stylesheet" type="text/css" href="../_static/searxng.css?v=52e4ff28" />
    <script src="../_static/documentation_options.js?v=ef740023"></script>
    <script src="../_static/doctools.js?v=9a2dae69"></script>
    <script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
    <script data-project="searxng" data-version="2025.1.6+6dab7fe78" src="../_static/describe_version.js?v=fa7f30d0"></script>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="Source-Code" href="../src/index.html" />
    <link rel="prev" title="utils/searxng.sh" href="searxng.sh.html" /> 
  </head><body>
    <div class="related" role="navigation" aria-label="Related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="../src/index.html" title="Source-Code"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="searxng.sh.html" title="utils/searxng.sh"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../index.html">SearXNG Documentation (2025.1.6+6dab7fe78)</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="index.html" accesskey="U">DevOps tooling box</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href=""><code class="docutils literal notranslate"><span class="pre">utils/lxc.sh</span></code></a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <section id="utils-lxc-sh">
<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>
<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
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
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
to care about</em>).</p>
<aside class="sidebar">
<p class="sidebar-title">further reading</p>
<ul class="simple">
<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>
<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>
<li><p><a class="reference external" href="https://uk.images.linuxcontainers.org/">LXC/LXD Image Server</a></p></li>
<li><p><a class="reference external" href="https://github.com/lxc/lxd">LXD&#64;github</a></p></li>
</ul>
</aside>
<nav class="contents local" id="contents">
<ul class="simple">
<li><p><a class="reference internal" href="#install-lxd" id="id5">Install LXD</a></p>
<ul>
<li><p><a class="reference internal" href="#internet-connectivity-docker" id="id6">Internet Connectivity &amp; Docker</a></p></li>
</ul>
</li>
<li><p><a class="reference internal" href="#searxng-lxc-suite" id="id7">SearXNG LXC suite</a></p>
<ul>
<li><p><a class="reference internal" href="#running-commands" id="id8">Running commands</a></p></li>
<li><p><a class="reference internal" href="#good-to-know" id="id9">Good to know</a></p></li>
<li><p><a class="reference internal" href="#install-suite" id="id10">Install suite</a></p></li>
<li><p><a class="reference internal" href="#clean-up" id="id11">Clean up</a></p></li>
</ul>
</li>
<li><p><a class="reference internal" href="#setup-searxng-buildhost" id="id12">Setup SearXNG buildhost</a></p></li>
<li><p><a class="reference internal" href="#command-help" id="id13">Command Help</a></p></li>
<li><p><a class="reference internal" href="#searxng-suite-config" id="id14">SearXNG suite config</a></p></li>
</ul>
</nav>
<section id="install-lxd">
<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>
<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>
once:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ snap install lxd
$ lxd init --auto
</pre></div>
</div>
<p>To make use of the containers from the <em>SearXNG suite</em>, you have to build the
<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
take some time</strong>:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ sudo -H ./utils/lxc.sh build
</pre></div>
</div>
<aside class="sidebar">
<p class="sidebar-title">hint</p>
<p>If you have issues with the internet connectivity of your containers read
section <a class="reference internal" href="#internet-connectivity-docker"><span class="std std-ref">Internet Connectivity &amp; Docker</span></a>.</p>
</aside>
<p>A cup of coffee later, your LXC suite is build up and you can run whatever task
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>
<section id="internet-connectivity-docker">
<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>
<aside class="sidebar">
<p class="sidebar-title">further read</p>
<ul class="simple">
<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>
<li><p><a class="reference external" href="https://fralef.me/docker-and-iptables.html">Docker and IPtables (fralef.me)</a></p></li>
<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>
</ul>
</aside>
<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
docker installed, you may find that the internet connectivity of your LXD
containers no longer work.</p>
<p>Whenever docker is started (reboot) it sets the iptables policy for the
<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>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ sudo -H iptables-save | grep FORWARD
:FORWARD ACCEPT [7048:7851230]
:FORWARD DROP [7048:7851230]
</pre></div>
</div>
<p>A handy solution of this problem might be to reset the policy for the
<code class="docutils literal notranslate"><span class="pre">FORWARD</span></code> chain after the network has been initialized.  For this create a
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>)
and insert the following lines:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="ch">#!/bin/sh</span>
<span class="n">iptables</span> <span class="o">-</span><span class="n">F</span> <span class="n">FORWARD</span>
<span class="n">iptables</span> <span class="o">-</span><span class="n">P</span> <span class="n">FORWARD</span> <span class="n">ACCEPT</span>
</pre></div>
</div>
<p>Don’t forget to set the execution bit:</p>
<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>
</pre></div>
</div>
<p>Reboot your system and check the iptables rules:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ sudo -H iptables-save | grep FORWARD
:FORWARD ACCEPT [7048:7851230]
:FORWARD ACCEPT [7048:7851230]
</pre></div>
</div>
</section>
</section>
<section id="searxng-lxc-suite">
<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>
<p>The intention of the <em>SearXNG LXC suite</em> is to build up a suite of containers
for development tasks or <a class="reference internal" href="#setup-searxng-buildhost"><span class="std std-ref">buildhosts</span></a> with a very
small set of simple commands.  At the end of the <code class="docutils literal notranslate"><span class="pre">--help</span></code> output the SearXNG
suite from the <a class="reference internal" href="#lxc-searxng-env"><span class="std std-ref">SearXNG suite config</span></a> is introduced:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ sudo -H ./utils/lxc.sh --help
...
LXC suite: searxng
  Suite includes installation of SearXNG
  images:     ubu2004 ubu2204 fedora35 archlinux
  containers: searxng-ubu2004 searxng-ubu2204 searxng-fedora35 searxng-archlinux
</pre></div>
</div>
<p>As shown above there are images and containers build up on this images.  To show
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>.
If this is the first time you make use of the SearXNG LXC suite, no containers
are installed and the output is:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ sudo -H ./utils/lxc.sh show suite

LXC suite (searxng-*)
=====================

+------+-------+------+------+------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+------+-------+------+------+------+-----------+

WARN:  container searxng-ubu2004 does not yet exists
WARN:  container searxng-ubu2204 does not yet exists
WARN:  container searxng-fedora35 does not yet exists
WARN:  container searxng-archlinux does not yet exists
</pre></div>
</div>
<p>If you do not want to run a command or a build in all containers, <strong>you can
build just one</strong>. Here by example in the container that is build upon the
<em>archlinux</em> image:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ sudo -H ./utils/lxc.sh build searxng-archlinux
$ sudo -H ./utils/lxc.sh cmd searxng-archlinux pwd
</pre></div>
</div>
<p>Otherwise, to apply a command to all containers you can use:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ sudo -H ./utils/lxc.sh build
$ sudo -H ./utils/lxc.sh cmd -- ls -la .
</pre></div>
</div>
<section id="running-commands">
<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>
<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
what ever command you need.  By example, to start a bash use:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ sudo -H ./utils/lxc.sh cmd searxng-archlinux bash
INFO:  [searxng-archlinux] bash
[root@searxng-archlinux SearXNG]#
</pre></div>
</div>
</section>
<section id="good-to-know">
<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>
<p>Each container shares the root folder of the repository and the command
<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>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ pwd
/share/SearXNG

$ sudo -H ./utils/lxc.sh cmd searxng-archlinux pwd
INFO:  [searxng-archlinux] pwd
/share/SearXNG
</pre></div>
</div>
<p>The path <code class="docutils literal notranslate"><span class="pre">/share/SearXNG</span></code> will be different on your HOST system.  The commands
in the container are executed by the <code class="docutils literal notranslate"><span class="pre">root</span></code> inside of the container.  Compare
output of:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ ls -li Makefile
47712402 -rw-rw-r-- 1 markus markus 2923 Apr 19 13:52 Makefile

$ sudo -H ./utils/lxc.sh cmd searxng-archlinux ls -li Makefile
INFO:  [searxng-archlinux] ls -li Makefile
47712402 -rw-rw-r-- 1 root root 2923 Apr 19 11:52 Makefile
...
</pre></div>
</div>
<p>Since the path <code class="docutils literal notranslate"><span class="pre">/share/SearXNG</span></code> of the HOST system is wrapped into the
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
the output is always the identical <code class="docutils literal notranslate"><span class="pre">/share/SearXNG/Makefile</span></code> from the HOST
system.  In the example shown above the owner of the path in the container is
the <code class="docutils literal notranslate"><span class="pre">root</span></code> user of the container (and the timezone in the container is
different to HOST system).</p>
</section>
<section id="install-suite">
<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>
<aside class="sidebar">
<p class="sidebar-title">further read</p>
<ul class="simple">
<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>
<li><p><a class="reference internal" href="index.html#force-timeout"><span class="std std-ref">FORCE_TIMEOUT</span></a></p></li>
</ul>
</aside>
<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>
containers leave the container argument empty and run:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ sudo -H ./utils/lxc.sh build
$ sudo -H ./utils/lxc.sh install suite
</pre></div>
</div>
<p>To <em>build &amp; install</em> suite only in one container you can use by example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ sudo -H ./utils/lxc.sh build searxng-archlinux
$ sudo -H ./utils/lxc.sh install suite searxng-archlinux
</pre></div>
</div>
<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>).
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
use <a class="reference internal" href="../admin/installation-apache.html#installation-apache"><span class="std std-ref">apache</span></a>):</p>
<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
</pre></div>
</div>
<p>Same operation just in one container of the suite:</p>
<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
</pre></div>
</div>
<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
script without user interaction.</p>
<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>
command.  To test instances from containers just open the URLs in your
WEB-Browser:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ sudo ./utils/lxc.sh show suite | grep SEARXNG_URL

[searxng-ubu2110]      SEARXNG_URL          : http://n.n.n.170/searxng
[searxng-ubu2004]      SEARXNG_URL          : http://n.n.n.160/searxng
[searxnggfedora35]     SEARXNG_URL          : http://n.n.n.150/searxng
[searxng-archlinux]    SEARXNG_URL          : http://n.n.n.140/searxng
</pre></div>
</div>
</section>
<section id="clean-up">
<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>
<p>If there comes the time you want to <strong>get rid off all</strong> the containers and
<strong>clean up local images</strong> just type:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ sudo -H ./utils/lxc.sh remove
$ sudo -H ./utils/lxc.sh remove images
</pre></div>
</div>
</section>
</section>
<section id="setup-searxng-buildhost">
<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>
<p>You can <strong>install the SearXNG buildhost environment</strong> into one or all containers.
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
time.  Installation in all containers will take more time (time for another cup
of coffee).</p>
<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>
</pre></div>
</div>
<p>To build (live) documentation inside a <a class="reference external" href="https://www.archlinux.org/">archlinux</a> container:</p>
<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>
<span class="o">...</span>
<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>
</pre></div>
</div>
<p>To get IP of the container and the port number <em>live docs</em> is listening:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ sudo ./utils/lxc.sh show suite | grep docs.live
...
[searxng-archlinux]  INFO:  (eth0) docs.live:  http://n.n.n.140:8080/
</pre></div>
</div>
</section>
<section id="command-help">
<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>
<p>The <code class="docutils literal notranslate"><span class="pre">--help</span></code> output of the script is largely self-explanatory:</p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>usage::
  lxc.sh build        [containers|&lt;name&gt;]
  lxc.sh copy         [images]
  lxc.sh remove       [containers|&lt;name&gt;|images]
  lxc.sh [start|stop] [containers|&lt;name&gt;]
  lxc.sh show         [images|suite|info|config [&lt;name&gt;]]
  lxc.sh cmd          [--|&lt;name&gt;] &#39;...&#39;
  lxc.sh install      [suite|base [&lt;name&gt;]]

build
  :containers:   build, launch all containers and &#39;install base&#39; packages
  :&lt;name&gt;:       build, launch container &lt;name&gt;  and &#39;install base&#39; packages
copy:
  :images:       copy remote images of the suite into local storage
remove
  :containers:   delete all &#39;containers&#39; or only &lt;container-name&gt;
  :images:       delete local images of the suite
start/stop
  :containers:   start/stop all &#39;containers&#39; from the suite
  :&lt;name&gt;:       start/stop container &lt;name&gt; from suite
show
  :info:         show info of all (or &lt;name&gt;) containers from LXC suite
  :config:       show config of all (or &lt;name&gt;) containers from the LXC suite
  :suite:        show services of all (or &lt;name&gt;) containers from the LXC suite
  :images:       show information of local images
cmd
  use single quotes to evaluate in container&#39;s bash, e.g.: &#39;echo $(hostname)&#39;
  --             run command &#39;...&#39; in all containers of the LXC suite
  :&lt;name&gt;:       run command &#39;...&#39; in container &lt;name&gt;
install
  :base:         prepare LXC; install basic packages
  :suite:        install LXC searxng suite into all (or &lt;name&gt;) containers

LXC suite: searxng
  Suite includes installation of SearXNG
  images:     ubu2004 ubu2204 fedora35 archlinux
  containers: searxng-ubu2004 searxng-ubu2204 searxng-fedora35 searxng-archlinux
</pre></div>
</div>
</section>
<section id="searxng-suite-config">
<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>
<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>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="c1"># -*- coding: utf-8; mode: sh indent-tabs-mode: nil -*-</span>
<span class="c1"># SPDX-License-Identifier: AGPL-3.0-or-later</span>
<span class="c1"># shellcheck shell=bash</span>

<span class="c1"># This file is a setup of a LXC suite.  It is sourced from different context, do</span>
<span class="c1"># not manipulate the environment directly, implement functions and manipulate</span>
<span class="c1"># environment only in subshells.</span>

lxc_set_suite_env<span class="o">()</span><span class="w"> </span><span class="o">{</span>

<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>

<span class="w">    </span><span class="c1"># name of https://images.linuxcontainers.org</span>
<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>
<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>
<span class="w">    </span><span class="nb">export</span><span class="w"> </span><span class="nv">LXC_SUITE</span><span class="o">=(</span>

<span class="w">        </span><span class="c1"># end of standard support see https://wiki.ubuntu.com/Releases</span>
<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>
<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>

<span class="w">        </span><span class="c1"># EOL see https://fedoraproject.org/wiki/Releases</span>
<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>

<span class="w">        </span><span class="c1"># rolling releases see https://www.archlinux.org/releng/releases/</span>
<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>
<span class="w">    </span><span class="o">)</span>
<span class="o">}</span>

lxc_suite_install_info<span class="o">()</span><span class="w"> </span><span class="o">{</span>
<span class="w">    </span><span class="o">(</span>
<span class="w">        </span>lxc_set_suite_env
<span class="w">        </span>cat<span class="w"> </span><span class="s">&lt;&lt;EOF</span>
<span class="s">LXC suite: ${LXC_SUITE_NAME}</span>
<span class="s">  Suite includes installation of SearXNG</span>
<span class="s">  images:     ${LOCAL_IMAGES[*]}</span>
<span class="s">  containers: ${CONTAINERS[*]}</span>
<span class="s">EOF</span>
<span class="w">    </span><span class="o">)</span>
<span class="o">}</span>

lxc_suite_install<span class="o">()</span><span class="w"> </span><span class="o">{</span>
<span class="w">    </span><span class="o">(</span>
<span class="w">        </span>lxc_set_suite_env
<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
<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
<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>
<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>
<span class="w">        </span><span class="k">fi</span>
<span class="w">        </span>lxc_suite_info
<span class="w">        </span><span class="nb">echo</span>
<span class="w">    </span><span class="o">)</span>
<span class="o">}</span>

lxc_suite_info<span class="o">()</span><span class="w"> </span><span class="o">{</span>
<span class="w">    </span><span class="o">(</span>
<span class="w">        </span>lxc_set_suite_env
<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>
<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>
<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>
<span class="w">            </span><span class="k">else</span>
<span class="w">                </span><span class="c1"># IPv4:</span>
<span class="w">                </span><span class="c1"># shellcheck disable=SC2034,SC2031</span>
<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>
<span class="w">            </span><span class="k">fi</span>
<span class="w">        </span><span class="k">done</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>searxng.instance.env
<span class="w">    </span><span class="o">)</span>
<span class="o">}</span>
</pre></div>
</div>
</section>
</section>


            <div class="clearer"></div>
          </div>
        </div>
      </div>
  <span id="sidebar-top"></span>
      <div class="sphinxsidebar" role="navigation" aria-label="Main">
        <div class="sphinxsidebarwrapper">
  
    
            <p class="logo"><a href="../index.html">
              <img class="logo" src="../_static/searxng-wordmark.svg" alt="Logo of SearXNG"/>
            </a></p>
  

<h3><a href="../index.html">Table of Contents</a></h3>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../user/index.html">User information</a></li>
<li class="toctree-l1"><a class="reference internal" href="../own-instance.html">Why use a private instance?</a></li>
<li class="toctree-l1"><a class="reference internal" href="../admin/index.html">Administrator documentation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../dev/index.html">Developer documentation</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="index.html">DevOps tooling box</a><ul class="current">
<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>
<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>
<li class="toctree-l3"><a class="reference internal" href="#install-lxd">Install LXD</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#internet-connectivity-docker">Internet Connectivity &amp; Docker</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#searxng-lxc-suite">SearXNG LXC suite</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#running-commands">Running commands</a></li>
<li class="toctree-l4"><a class="reference internal" href="#good-to-know">Good to know</a></li>
<li class="toctree-l4"><a class="reference internal" href="#install-suite">Install suite</a></li>
<li class="toctree-l4"><a class="reference internal" href="#clean-up">Clean up</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#setup-searxng-buildhost">Setup SearXNG buildhost</a></li>
<li class="toctree-l3"><a class="reference internal" href="#command-help">Command Help</a></li>
<li class="toctree-l3"><a class="reference internal" href="#searxng-suite-config">SearXNG suite config</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="index.html#common-command-environments">Common command environments</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../src/index.html">Source-Code</a></li>
</ul>

  <h3>Project Links</h3>
  <ul>
    <li><a href="https://github.com/searxng/searxng/tree/master">Source</a>
  
    <li><a href="https://github.com/searxng/searxng/wiki">Wiki</a>
  
    <li><a href="https://searx.space">Public instances</a>
  
    <li><a href="https://github.com/searxng/searxng/issues">Issue Tracker</a>
  </ul><h3>Navigation</h3>
<ul>
  <li><a href="../index.html">Overview</a>
    <ul>
      <li><a href="index.html">DevOps tooling box</a>
        <ul>
          <li>Previous: <a href="searxng.sh.html" title="previous chapter"><code class="docutils literal notranslate"><span class="pre">utils/searxng.sh</span></code></a>
          <li>Next: <a href="../src/index.html" title="next chapter">Source-Code</a></ul>
      </li>
    </ul>
  </li>
</ul>
<search id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>
    </div>
</search>
<script>document.getElementById('searchbox').style.display = "block"</script>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../_sources/utils/lxc.sh.rst.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="footer" role="contentinfo">
    &#169; Copyright SearXNG team.
    </div>
  </body>
</html>