For demonstration, I added these lines to a fresh install of mosquitto-2.0.10_1 on FreeBSD 13.0-RELEASE-p4. They are placed just before the 'run_rc_command' line in /usr/local/etc/rc.d/mosquitto : echo mosquitto_enable=$mosquitto_enable echo mosquitto_config=$mosquitto_config echo mosquitto_user=$mosquitto_user echo mosquitto_pidfile=$mosquitto_pidfile echo pidfile=$pidfile I am running with this configuration: $ grep mosq /etc/rc.conf mosquitto_enable="YES" mosquitto_user="mosquitto" mosquitto_pidfile="/var/run/mosquitto/mosquitto.pid" $ sudo service mosquitto start mosquitto_enable=YES mosquitto_config=/usr/local/etc/mosquitto/mosquitto.conf mosquitto_user=mosquitto mosquitto_pidfile=/var/run/mosquitto/mosquitto.pid pidfile=/var/run/mosquitto.pid Starting mosquitto. NOTE how pidfile has the wrong value but mosquitto_pidfile does. Both files are created, but only one is correct. $ sudo ls -l /var/run/mosquitto/mosquitto.pid /var/run/mosquitto.pid -rw-r--r-- 1 mosquitto wheel 0 Aug 27 15:10 /var/run/mosquitto.pid -rw-r--r-- 1 mosquitto mosquitto 5 Aug 27 15:10 /var/run/mosquitto/mosquitto.pid Clearly, the value for mosquitto_pidfile is not being picked up from /etc/rc.conf I'm submitting this now and may be able to work on finding a solution soon.
The fix is to move "load_rc_config $name" before the variable assignments. Credit to jrm via IRC and eborisch via Twitter for this. [dan@gelt:/usr/local/etc/rc.d] $ diff -ruN mosquitto mosquitto.mine --- mosquitto 2021-08-22 04:34:48.000000000 +0000 +++ mosquitto.mine 2021-08-27 16:45:52.963755000 +0000 @@ -19,6 +19,7 @@ name=mosquitto rcvar=mosquitto_enable +load_rc_config $name mosquitto_enable=${mosquitto_enable:="NO"} mosquitto_config=${mosquitto_config:="/usr/local/etc/mosquitto/mosquitto.conf"} mosquitto_user=${mosquitto_user:="nobody"} @@ -40,5 +41,10 @@ install -o ${mosquitto_user} -m 644 /dev/null ${pidfile} } -load_rc_config $name +echo mosquitto_enable=$mosquitto_enable +echo mosquitto_config=$mosquitto_config +echo mosquitto_user=$mosquitto_user +echo mosquitto_pidfile=$mosquitto_pidfile +echo pidfile=$pidfile + run_rc_command "$1" [dan@gelt:/usr/local/etc/rc.d] $
Created attachment 227488 [details] fixes assignment of /etc/rc.conf variables Credit to jrm for this script. Tested on my hosts. NOTE: when setting mosquitto_pidfile in /etc/rc.conf, you must also set pid_file (note the underscore) to the same value within the mosquitto configuration file.
Joe: I take it we have maintainer approval to proceed? Just to be explicit. Thank you.
Yes, the changes seem very reasonable. -Joe
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/ports/commit/?id=921e007cc543520bac1adf9e96de9483cb3e725e commit 921e007cc543520bac1adf9e96de9483cb3e725e Author: Dan Langille <dvl@FreeBSD.org> AuthorDate: 2021-08-27 21:35:40 +0000 Commit: Dan Langille <dvl@FreeBSD.org> CommitDate: 2021-08-27 21:55:16 +0000 net/mosquitto: update rc.d script to fix mosquitto_pidfile override The default variables were being set before load_rc_config was invoked. jrm@FreeBSD.org did most of this work and all credit goes to him. I only found the problem. He helped tremendously. PR: 258089 Reported by: dvl Approved by: joe@thrallingpenguin.com (maintainer) Obtained from: jrm net/mosquitto/Makefile | 2 +- net/mosquitto/files/mosquitto.in | 17 +++++------------ 2 files changed, 6 insertions(+), 13 deletions(-)
Thank you both.