You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
621 B
Bash
29 lines
621 B
Bash
4 months ago
|
#!/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!"
|