Hi, I've installed openwrt 19.07.04 on a Fritzbox 7360 SL router. It has no internet connection and should work as an additionell AP only within my network.
For homeautomation there is running mqtt-broker mosquitto-nossl. In the GUI there is visible the additionell service - mosquitto.
For flash memory protection I've installed USB support and mounted the stick as /dev/sda1/ at boot.
The mosquitto.conf file contains:
# =================================================================
# General configuration
# =================================================================
# Port to use for the default listener.
port 1883
# anonymous
allow_anonymous false
# persistence
persistence true
# name of the file for persistence
persistence_file mosquitto.db
# location of the file for persistence
persistence_location /mnt/sda1/mosquitto/
#how often to save to the persistence file
autosave_interval 1800
log_timestamp true
log_dest file /mnt/sda1/mosquitto/mosquitto.log
log_dest stdout
password_file /mnt/sda1/mosquitto/passwords.txt
The issue: Log-file or db-file will not be created. Any mosquitto command like mosquitto_passwd, are ignored with error message: command not found
All packages were installed and are running from root perspective, so all mosquitto-files have root ownership and root permissions.
Starting the mosquitto service using the ssh command mosquitto -c /etc/mosquitto/mosquitto.conf this gives the result at console:
root@OpenWrt:~# mosquitto -c /etc/mosquitto/mosquitto.conf
1604592752: mosquitto version 1.6.12 starting
1604592752: Config loaded from /etc/mosquitto/mosquitto.conf.
1604592752: Opening ipv4 listen socket on port 1883.
1604592752: Error: Address in use
What does it mean? The router has a fix IP 192.168.x.5. It works as an WiFi AP without DHCP and I assume that the mosquitto service is reachable by the same address.
Further: The SystemLog of OpenWrt router responses with the message:
Wed Nov 4 17:27:57 2020 daemon.notice procd: /etc/rc.d/S80mosquitto: sh: out of range
Unfortunately I'm not familiar with openwrt programming and have no idea how to interprete these massages.
After some sleppless nights I got it ! Hopefully my investigations can help other users.
Mosquitto runs as a service and creates an hidden user "mosquitto" for its own. It will be visible with command cat /etc/passwd.
Starting mosquitto for the first time as described above (mosquitto -c /etc/mosquitto/mosquitto.conf) the mosquitto user should create files: mosquitto.log, mosquitto.db
at usb stick location /mnt/sda1/mosquitto/ - but this location is owned by user root, because usb packages installation/configuration was done from root perspective.
It's quiet strange: The log file is created, but the mosquitto.db isn't and passwords.txt isn't used for authentication too.
Unfortunately the log file doesn't show any hints, why the persistence file isn't written.
Therefore I used WinSCP/putty to extend the folder permissions temporarily to 0777. Restarting the mosquitto service I got:
Interesting:
The persistence file was created and the formerly generated and encrypted file passwords.txt owned by user root was taken over by user mosquitt(o - only 8 characters allowed)