#!/bin/sh # Runs mosquitto and reloads it (SIGHUP → re-reads password_file + acl_file) whenever the # backend provisions a new per-device credential and touches the reload trigger. Same # container as mosquitto, so it can signal it — no docker socket, no restart needed. set -e mosquitto -c /mosquitto/config/mosquitto.conf & MPID=$! trap 'kill -TERM "$MPID" 2>/dev/null; exit 0' TERM INT TRIGGER=/mosquitto/config/reload LAST=$(stat -c %Y "$TRIGGER" 2>/dev/null || echo 0) while kill -0 "$MPID" 2>/dev/null; do CUR=$(stat -c %Y "$TRIGGER" 2>/dev/null || echo 0) if [ "$CUR" != "$LAST" ]; then kill -HUP "$MPID" 2>/dev/null || true LAST="$CUR" fi sleep 2 done wait "$MPID"