Mosquitto from Source

From Da Nerd Mage Wiki
Revision as of 19:22, 3 March 2024 by Tinker (talk | contribs) (→‎Use it:)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Proven on:
Logo Debian.png
12 (bookworm)


The required tools:

  • apt install git build-essential autoconf cmake

Get the source:

  • git clone https://github.com/eclipse/mosquitto.git

The prerequisites:

  • apt install libc-ares-dev libwebsockets-dev libssl-dev xsltproc docbook-xsl libsystemd-dev libwrap0-dev openssl
  • # cJSON
    • git clone https://github.com/DaveGamble/cJSON
    • cd cJSON
    • mkdir build
    • cd build
    • cmake ..
    • make
    • sudo make install
    • cd ../..
  • # uthash / utlist
    • git clone https://github.com/troydhanson/uthash
    • cp uthash/src/* mosquitto/include
  • # For testing
    • apt install python3-psutil
    • git clone https://gitlab.com/cunity/cunit.git
    • cd cunit
    • mkdir local-build
    • cd local-build
    • cmake ..
    • cmake --build .
    • sudo make install
    • cd ../..

Build it:

  • cd mosquitto
  • make

Test it:

  • make test

or

  • make check

Note: There are a fairly large number of tests that bring this to a grinding halt unless you comment them out. MUCH more research is needed...

24/1474 tests fail...

18 of those make the test procedure halt...

Install it:

  • adduser --system --group mosquitto
  • sudo make install
  • sudo cp /etc/mosquitto/mosquitto.conf.example /etc/mosquitto/mosquitto.conf

Enable it as a systemd service:

  • sudo cp service/systemd/mosquitto.service.simple /etc/systemd/system/mosquitto.service
  • sudo vi /etc/systemd/system/mosquitto.service

Fix the location in line 8.

The install step on Debian puts the executable in /usr/local/sbin not /usr/sbin

  • sudo systemctl daemon-reload
  • sudo systemctl restart mosquitto.service

To be done:

Configure it:

Default configuration works just fine like a default install from the repos...

That said...

  • sudo vi /etc/mosquitto/mosquitto.conf

For now, take a look at the huge selection of options in there.

After making any changes:

  • sudo service mosquitto restart

Use it:

This is a very deep rabbit hole.

Resources