created setup script

This commit is contained in:
root
2023-11-17 10:07:18 -06:00
parent 57888f7fbf
commit 7923acafed
5 changed files with 44 additions and 18 deletions

22
scripts/create_password.sh Executable file
View File

@@ -0,0 +1,22 @@
#!/bin/bash
SCRIPT_DIR=$(readlink -f $(dirname "${BASH_SOURCE[0]}"))
REPO_DIR=$(dirname $SCRIPT_DIR)
COMPOSE_FILE=$REPO_DIR/docker-compose.yml
ENV_FILE=$REPO_DIR/.env
if [ ! -f "$ENV_FILE" ]; then
echo "Error: .env file not found."
exit 1
else
source "$ENV_FILE"
fi
if [ -z "$MOSQUITTO_PASSWORD" ]; then
echo "MOSQUITTO_PASSWORD is not set. Exiting."
exit 1
fi
docker compose -f $COMPOSE_FILE run -it --rm mqtt mosquitto_passwd -b -c /mosquitto/config/pwfile homeassistant $MOSQUITTO_PASSWORD
echo "password: $MOSQUITTO_PASSWORD" > $REPO_DIR/zigbee2mqtt/secret.yaml