New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The missing documentation for using the mosquitto "snap" package on Ubuntu #931
Comments
I agree this is something that needs documenting, there are definitely some quirks to it. I've edited your comment to clear up some of the points, I hope that is alright. |
Is /etc no longerused with snap files? It's pretty annoying if snaps change /etc it's a reasonable assumption that config is in /etc for pretty much anything. |
That's right, a normal snap package only has access to specific paths, and that doesn't include anything in /etc. |
Feel free to move this to the documentation. |
Does anyone know how to clean the db? On normal installation I see a mosquitto.db that can be deleted while the service is down. But on Snapinstall there is no mosquitto.db (or I cannot find it) |
As stated in the configuration man page (https://mosquitto.org/man/mosquitto-conf-5.html) the persistence is off by default, so the data are stored in memory.
|
Makes sence! |
If you are using the latest version of mosquitto on Ubuntu, which is packaged as a "snap", then you'll need to know how to configure it.
Here is the missing documentation:
Using Mosquitto as a "snap" file on Ubuntu
Without other configuration, mosquitto loads a default configuration file from
$SNAP_COMMON/default_config.conf
.$SNAP_COMMON
is set to/var/snap/mosquitto/common
on Ubuntu, I don't know if it is different on other OSs.If you want to use your own configuration, put it in
$SNAP_COMMON/mosquitto.conf
i.e.
/var/snap/mosquitto/common/mosquitto.conf
This is the only file that will be used for the configuration. You can use
include_dir
, but it must point to a location inside /var/snap/mosquitto/common/ - try/var/snap/mosquitto/common/conf.d/
If you run the mosquitto manually as a normal user, the configuration will be loaded from
$SNAP_USER_COMMON/mosquitto.conf
, i.e./home/<user>/snap/mosquitto/common/mosquitto.conf
, but this will change soon so that you can specify any configuration file you want as is the usual mosquitto behaviour. Your configuration file will still need to be inside $SNAP_USER_COMMON.In all cases, for mosquitto 1.5.1 and earlier, you will need to add
user root
to your configuration file so that mosquitto does not try to drop privileges to themosquitto
user. Snaps do not support this changing of user, but the mosquitto snap is strictly confined so it poses a minimal risk.general tip: to list the systemd mosquitto service unit files
general tip: to stop the mosquitto service:
sudo systemctl stop snap.mosquitto.mosquitto.service
general tip: to start the mosquitto service
sudo systemctl start snap.mosquitto.mosquitto.service
general tip: to find out the current status of the mosquitto service
sudo systemctl status snap.mosquitto.mosquitto.service
general tip: to see the mosquitto service log messages:
sudo journalctl -f -u snap.mosquitto.mosquitto.service
mosquitto will not start if your config file has include_dir /etc/mosquitto/conf.d because it cannot find the directory
to do a test message publish, on the same machine as the server:
mosquitto_sub -h localhost -t test
and on the same machine in a different console:
mosquitto_pub -h localhost -t test -m atestmessage
The text was updated successfully, but these errors were encountered: