Compare commits
10 Commits
5dfb2f3918
...
ee7fa752bc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ee7fa752bc | ||
|
|
36d7745289 | ||
|
|
730f0cdf17 | ||
|
|
408b491ba1 | ||
|
|
4780bc887b | ||
|
|
7a8ef0bd85 | ||
|
|
5ceae952a1 | ||
|
|
070ecf778a | ||
|
|
588de129eb | ||
|
|
d872f005af |
@@ -7,9 +7,6 @@ Zigbee smarthome stack
|
||||
|
||||
## Setup
|
||||
|
||||
1. Create `.env` file with `MOSQUITTO_PASSWORD`.
|
||||
2. Run setup script
|
||||
|
||||
```
|
||||
./scripts/setup.sh
|
||||
```
|
||||
```
|
||||
./scripts/setup.sh
|
||||
```
|
||||
|
||||
@@ -7,24 +7,18 @@ services:
|
||||
volumes:
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
- /etc/timezone:/etc/timezone:ro
|
||||
- ./mosquitto:/mosquitto
|
||||
- ./mosquitto/config:/mosquitto/config
|
||||
- ./mosquitto/data:/mosquitto/data
|
||||
- ./mosquitto/log:/mosquitto/log
|
||||
ports:
|
||||
- 1883:1883
|
||||
healthcheck:
|
||||
test: ["CMD", "mosquitto_sub", "-t", "$$SYS/#", "-C", "1", "-i", "healthcheck", "-W", "3", "--port", "1880"]
|
||||
start_period: 15s
|
||||
start_interval: 1s
|
||||
interval: 5s
|
||||
timeout: 10s
|
||||
retries: 5
|
||||
|
||||
z2m:
|
||||
container_name: zigbee2mqtt
|
||||
image: koenkk/zigbee2mqtt
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
mqtt:
|
||||
condition: service_healthy
|
||||
- mqtt
|
||||
volumes:
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
- /etc/timezone:/etc/timezone:ro
|
||||
|
||||
0
mosquitto/log/.gitkeep
Normal file
0
mosquitto/log/.gitkeep
Normal file
@@ -1,13 +1,34 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
cleanup_except() {
|
||||
local directory=$1
|
||||
local except_file=$2
|
||||
|
||||
# Check if the directory exists
|
||||
if [[ ! -d "$directory" ]]; then
|
||||
echo "Directory does not exist: $directory"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Loop over each file in the directory
|
||||
for file in "$directory"/*
|
||||
do
|
||||
if [[ "$(basename "$file")" != "$except_file" ]]; then
|
||||
# Delete the file
|
||||
rm -rf "$file"
|
||||
echo "Removed $file"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
SCRIPT_DIR=$(readlink -f $(dirname "${BASH_SOURCE[0]}"))
|
||||
REPO_DIR=$(dirname $SCRIPT_DIR)
|
||||
COMPOSE_FILE=$REPO_DIR/docker-compose.yml
|
||||
|
||||
rm -rf \
|
||||
$REPO_DIR/mosquitto/config/pwfile \
|
||||
$REPO_DIR/mosquitto/data/mosquitto.db \
|
||||
$REPO_DIR/zigbee2mqtt/secret.yaml \
|
||||
$REPO_DIR/zigbee2mqtt/*.json \
|
||||
$REPO_DIR/zigbee2mqtt/log/* \
|
||||
$REPO_DIR/zigbee2mqtt/database.db \
|
||||
docker compose -f $COMPOSE_FILE down
|
||||
|
||||
cleanup_except "$REPO_DIR/mosquitto/config" mosquitto.conf
|
||||
cleanup_except "$REPO_DIR/mosquitto/data" .gitkeep
|
||||
cleanup_except "$REPO_DIR/mosquitto/log"
|
||||
cleanup_except "$REPO_DIR/zigbee2mqtt" configuration.yaml
|
||||
|
||||
@@ -1,22 +1,15 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
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
|
||||
echo "Please the mosquitto password:"
|
||||
read -s MOSQUITTO_PASSWORD
|
||||
|
||||
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
|
||||
chmod 600 $REPO_DIR/zigbee2mqtt/secret.yaml
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR=$(readlink -f $(dirname "${BASH_SOURCE[0]}"))
|
||||
REPO_DIR=$(dirname $SCRIPT_DIR)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
homeassistant: true
|
||||
permit_join: true
|
||||
mqtt:
|
||||
base_topic: zigbee2mqtt
|
||||
client_id: Zigbee2MQTT
|
||||
|
||||
Reference in New Issue
Block a user