I have a working flow using MQTT publisher and subscribe nodes and one broker configuration. Everything works.
Before starting up NodeRED, I have to change the MQTT broker ip and port with environment variables MQTT_BROKER_IP and MQTT_BROKER_PORT.
To do that I use
sed -i -e "s/^\([[:blank:]]*\"broker\":[[:blank:]]*\)\"[^\"]*\",/\1\"$MQTT_BROKER_IP\",/g" /data/flows.json
sed -i -e "s/^\([[:blank:]]*\"port\":[[:blank:]]*\)\"[^\"]*\",/\1\"$MQTT_BROKER_PORT\",/g" /data/flows.json
The substitutions works.
Now, the problem is, that when NodeRED starts up there is an error in the logfile:
[info] Starting flows
[error] [mqtt out:2b1fba1a.efa24e] missing broker configuration
[error] [mqtt in:58c7bd6b.0e8664] missing broker configuration
When I go to the NodeRED Editor, open the MQTT nodes, save them without modifying anything and deploy the flow, everything works and the MQTT nodes get a green "connected" light.
Why does this happen? How do I have to modify flows.json outside NodeRED correctly?