2020-03-30 16:47:01 +00:00
|
|
|
|
|
|
|
.. _snap: https://snapcraft.io
|
|
|
|
.. _snapcraft LXD: https://snapcraft.io/lxd
|
|
|
|
.. _LXC/LXD Image Server: https://uk.images.linuxcontainers.org/
|
|
|
|
.. _LXC: https://linuxcontainers.org/lxc/introduction/
|
|
|
|
.. _LXD: https://linuxcontainers.org/lxd/introduction/
|
|
|
|
.. _`LXD@github`: https://github.com/lxc/lxd
|
|
|
|
|
2020-03-31 16:25:40 +00:00
|
|
|
.. _archlinux: https://www.archlinux.org/
|
|
|
|
|
2020-03-30 16:47:01 +00:00
|
|
|
.. _lxc.sh:
|
|
|
|
|
|
|
|
================
|
|
|
|
``utils/lxc.sh``
|
|
|
|
================
|
|
|
|
|
|
|
|
.. sidebar:: further reading
|
|
|
|
|
|
|
|
- snap_, `snapcraft LXD`_
|
|
|
|
- LXC_, LXD_
|
|
|
|
- `LXC/LXD Image Server`_
|
|
|
|
- `LXD@github`_
|
|
|
|
|
|
|
|
With the use of *Linux Containers* (LXC_) we can scale our tasks over a stack of
|
2021-09-12 06:36:56 +00:00
|
|
|
containers, what we call the: *lxc suite*. The *SearXNG suite*
|
2022-05-27 16:43:14 +00:00
|
|
|
(:origin:`lxc-searxng.env <utils/lxc-searxng.env>`) is loaded by default, every time
|
2020-03-31 16:25:40 +00:00
|
|
|
you start the ``lxc.sh`` script (*you do not need to care about*).
|
|
|
|
|
|
|
|
Before you can start with containers, you need to install and initiate LXD_
|
|
|
|
once::
|
2020-03-30 16:47:01 +00:00
|
|
|
|
|
|
|
$ snap install lxd
|
|
|
|
$ lxd init --auto
|
|
|
|
|
2021-09-12 06:36:56 +00:00
|
|
|
To make use of the containers from the *SearXNG suite*, you have to build the
|
2020-04-03 15:08:42 +00:00
|
|
|
:ref:`LXC suite containers <lxc.sh help>` initial. But be warned, **this might
|
|
|
|
take some time**::
|
2020-03-30 16:47:01 +00:00
|
|
|
|
|
|
|
$ sudo -H ./utils/lxc.sh build
|
|
|
|
|
|
|
|
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 :ref:`LXC suite containers <lxc.sh
|
2021-06-23 10:39:49 +00:00
|
|
|
help>`.
|
|
|
|
|
|
|
|
.. hint::
|
|
|
|
|
|
|
|
If you see any problems with the internet connectivity of your
|
|
|
|
containers read section :ref:`internet connectivity docker`.
|
|
|
|
|
|
|
|
If you do not want to build all containers, **you can build just one**::
|
2020-04-03 15:08:42 +00:00
|
|
|
|
2022-06-14 08:02:50 +00:00
|
|
|
$ sudo -H ./utils/lxc.sh build searxng-archlinux
|
2020-03-31 16:25:40 +00:00
|
|
|
|
|
|
|
*Good to know ...*
|
|
|
|
|
2020-06-24 15:49:38 +00:00
|
|
|
Each container shares the root folder of the repository and the command
|
|
|
|
``utils/lxc.sh cmd`` **handles relative path names transparent**, compare output
|
|
|
|
of::
|
2020-03-30 16:47:01 +00:00
|
|
|
|
|
|
|
$ sudo -H ./utils/lxc.sh cmd -- ls -la Makefile
|
|
|
|
...
|
2020-04-03 15:08:42 +00:00
|
|
|
|
|
|
|
In the containers, you can run what ever you want, e.g. to start a bash use::
|
|
|
|
|
2022-06-14 08:02:50 +00:00
|
|
|
$ sudo -H ./utils/lxc.sh cmd searxng-archlinux bash
|
|
|
|
INFO: [searxng-archlinux] bash
|
|
|
|
[root@searxng-archlinux SearXNG]#
|
2020-03-30 16:47:01 +00:00
|
|
|
|
2020-03-31 16:25:40 +00:00
|
|
|
If there comes the time you want to **get rid off all** the containers and
|
|
|
|
**clean up local images** just type::
|
2020-03-30 16:47:01 +00:00
|
|
|
|
2020-03-31 16:25:40 +00:00
|
|
|
$ sudo -H ./utils/lxc.sh remove
|
|
|
|
$ sudo -H ./utils/lxc.sh remove images
|
2020-03-30 16:47:01 +00:00
|
|
|
|
2021-06-23 10:39:49 +00:00
|
|
|
.. _internet connectivity docker:
|
|
|
|
|
|
|
|
Internet Connectivity & Docker
|
|
|
|
==============================
|
|
|
|
|
|
|
|
.. sidebar:: further read
|
|
|
|
|
|
|
|
- `Docker blocking network of existing LXC containers <https://github.com/docker/for-linux/issues/103>`__
|
|
|
|
- `Docker and IPtables (fralef.me) <https://fralef.me/docker-and-iptables.html>`__
|
|
|
|
- `Docker and iptables (docker.com) <https://docs.docker.com/network/iptables/#docker-on-a-router/>`__
|
|
|
|
|
|
|
|
There is a conflict in the ``iptables`` setup of Docker & LXC. If you have
|
|
|
|
docker installed, you may find that the internet connectivity of your LXD
|
|
|
|
containers no longer work.
|
|
|
|
|
|
|
|
Whenever docker is started (reboot) it sets the iptables policy for the
|
|
|
|
``FORWARD`` chain to ``DROP`` `[ref]
|
|
|
|
<https://docs.docker.com/network/iptables/#docker-on-a-router>`__::
|
|
|
|
|
|
|
|
$ sudo -H iptables-save | grep FORWARD
|
|
|
|
:FORWARD ACCEPT [7048:7851230]
|
|
|
|
:FORWARD DROP [7048:7851230]
|
|
|
|
|
|
|
|
A handy solution of this problem might be to reset the policy for the
|
|
|
|
``FORWARD`` chain after the network has been initialized. For this create a
|
|
|
|
file in the ``if-up`` section of the network (``/etc/network/if-up.d/iptable``)
|
|
|
|
and insert the following lines::
|
|
|
|
|
|
|
|
#!/bin/sh
|
|
|
|
iptables -F FORWARD
|
|
|
|
iptables -P FORWARD ACCEPT
|
|
|
|
|
|
|
|
Don't forget to set the execution bit::
|
|
|
|
|
|
|
|
sudo chmod ugo+x /etc/network/if-up.d/iptable
|
|
|
|
|
|
|
|
Reboot your system and check the iptables rules::
|
|
|
|
|
|
|
|
$ sudo -H iptables-save | grep FORWARD
|
|
|
|
:FORWARD ACCEPT [7048:7851230]
|
|
|
|
:FORWARD ACCEPT [7048:7851230]
|
|
|
|
|
|
|
|
|
2020-06-24 15:49:38 +00:00
|
|
|
.. _lxc.sh install suite:
|
2020-03-30 16:47:01 +00:00
|
|
|
|
2020-03-31 16:25:40 +00:00
|
|
|
Install suite
|
|
|
|
=============
|
2020-03-30 16:47:01 +00:00
|
|
|
|
2021-09-12 06:36:56 +00:00
|
|
|
To install the complete :ref:`SearXNG suite (includes searx, morty & filtron)
|
2022-05-27 16:43:14 +00:00
|
|
|
<lxc-searxng.env>` into all LXC_ use::
|
2020-03-30 16:47:01 +00:00
|
|
|
|
2020-03-31 16:25:40 +00:00
|
|
|
$ sudo -H ./utils/lxc.sh install suite
|
2020-03-30 16:47:01 +00:00
|
|
|
|
2022-05-27 16:43:14 +00:00
|
|
|
The command above installs a SearXNG suite (see :ref:`installation scripts`).
|
|
|
|
To :ref:`install a nginx <installation nginx>` reverse proxy (or alternatively
|
|
|
|
use :ref:`apache <installation apache>`)::
|
|
|
|
|
|
|
|
sudo -H ./utils/lxc.sh cmd -- FORCE_TIMEOUT=0 ./utils/searxng.sh install nginx
|
|
|
|
|
|
|
|
To get the IP (URL) of the SearXNG service in the containers use ``show suite``
|
2020-03-31 16:25:40 +00:00
|
|
|
command. To test instances from containers just open the URLs in your
|
|
|
|
WEB-Browser::
|
2020-03-30 16:47:01 +00:00
|
|
|
|
2022-05-27 16:43:14 +00:00
|
|
|
$ sudo ./utils/lxc.sh show suite | grep SEARXNG_URL
|
2020-04-19 10:34:37 +00:00
|
|
|
|
2022-05-27 16:43:14 +00:00
|
|
|
[searxng-ubu2110] SEARXNG_URL : http://n.n.n.147/searxng
|
|
|
|
[searxng-ubu2004] SEARXNG_URL : http://n.n.n.246/searxng
|
|
|
|
[searxnggfedora35] SEARXNG_URL : http://n.n.n.140/searxng
|
|
|
|
[searxng-archlinux] SEARXNG_URL : http://n.n.n.165/searxng
|
2020-04-08 16:38:36 +00:00
|
|
|
|
|
|
|
|
2020-03-31 16:25:40 +00:00
|
|
|
Running commands
|
|
|
|
================
|
2020-03-30 16:47:01 +00:00
|
|
|
|
2020-03-31 16:25:40 +00:00
|
|
|
**Inside containers, you can use make or run scripts** from the
|
|
|
|
:ref:`toolboxing`. By example: to setup a :ref:`buildhosts` and run the
|
|
|
|
Makefile target ``test`` in the archlinux_ container::
|
|
|
|
|
2022-06-14 08:02:50 +00:00
|
|
|
sudo -H ./utils/lxc.sh cmd searxng-archlinux ./utils/searxng.sh install buildhost
|
|
|
|
sudo -H ./utils/lxc.sh cmd searxng-archlinux make test
|
2020-03-31 16:25:40 +00:00
|
|
|
|
|
|
|
|
2021-09-12 06:36:56 +00:00
|
|
|
Setup SearXNG buildhost
|
|
|
|
=======================
|
2020-03-30 16:47:01 +00:00
|
|
|
|
2021-09-12 06:36:56 +00:00
|
|
|
You can **install the SearXNG buildhost environment** into one or all containers.
|
2020-03-31 16:25:40 +00:00
|
|
|
The installation procedure to set up a :ref:`build host<buildhosts>` takes its
|
|
|
|
time. Installation in all containers will take more time (time for another cup
|
|
|
|
of coffee).::
|
|
|
|
|
2022-05-27 16:43:14 +00:00
|
|
|
sudo -H ./utils/lxc.sh cmd -- ./utils/searxng.sh install buildhost
|
2020-03-31 16:25:40 +00:00
|
|
|
|
|
|
|
To build (live) documentation inside a archlinux_ container::
|
|
|
|
|
2022-06-14 08:02:50 +00:00
|
|
|
sudo -H ./utils/lxc.sh cmd searxng-archlinux make docs.clean docs.live
|
2020-03-31 16:25:40 +00:00
|
|
|
...
|
|
|
|
[I 200331 15:00:42 server:296] Serving on http://0.0.0.0:8080
|
|
|
|
|
|
|
|
To get IP of the container and the port number *live docs* is listening::
|
|
|
|
|
2021-04-18 10:12:03 +00:00
|
|
|
$ sudo ./utils/lxc.sh show suite | grep docs.live
|
2020-03-31 16:25:40 +00:00
|
|
|
...
|
2022-06-14 08:02:50 +00:00
|
|
|
[searxng-archlinux] INFO: (eth0) docs.live: http://n.n.n.12:8080/
|
2020-03-31 16:25:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
.. _lxc.sh help:
|
2020-03-30 16:47:01 +00:00
|
|
|
|
|
|
|
Overview
|
|
|
|
========
|
|
|
|
|
|
|
|
The ``--help`` output of the script is largely self-explanatory:
|
|
|
|
|
|
|
|
.. program-output:: ../utils/lxc.sh --help
|
|
|
|
|
2020-03-31 16:25:40 +00:00
|
|
|
|
2022-05-27 16:43:14 +00:00
|
|
|
.. _lxc-searxng.env:
|
2020-03-31 16:25:40 +00:00
|
|
|
|
2021-09-12 06:36:56 +00:00
|
|
|
SearXNG suite
|
|
|
|
=============
|
2020-03-31 16:25:40 +00:00
|
|
|
|
2022-05-27 16:43:14 +00:00
|
|
|
.. literalinclude:: ../../utils/lxc-searxng.env
|
2020-03-31 16:25:40 +00:00
|
|
|
:language: bash
|