#!/usr/bin/env bash set -euo pipefail # shellcheck source=/dev/null source "$(dirname "$0")/common.sh" USER="$1" PASSWD="$2" if [ -z "$USER" ]; then echo "Error must provide a user name as first argument" exit 1 fi if [ -z "$PASSWD" ]; then echo "Error must provide a user name as first argument" exit 1 fi echo "Checking Mosquitto is running..." if ! check_port 1883 || ! check_port 9001; then echo "Mosquitto port 1883 or 9001 not found running" fi echo "Adding Mosquitto user ${USER}" docker exec mosquitto mosquitto_passwd -b /etc/mosquitto/passwd "${USER}" "${PASSWD}" echo "User added!"