I am trying to set remote_client ID using a value from the system environment variables instead of hardcoding it in the mosquitto.conf configuration file.
Is it possible to pass it inline when starting mosquitto such as:
mosquitto -remote_clientid $envar
Or can I refer environment variables directly from inside the config file?
remote_clientid $envar
I have not tested this, but you can run mosquitto
with -c CONFIGFILE
, so if you don't want to change your actual mosquitto.conf
on disk, you should be able to use a "process substitution" to pass a modified copy of your conf file like this in bash
:
mosquitto -c <(sed "s/remote_clientid=.*/remote_clientid=$CONFIGVAR" /etc/mosquitto.conf)
Note that this is a bash-ism so you need to be using bash
shell.