Compare commits

...

10 Commits

Author SHA1 Message Date
root
ee7fa752bc removed permit_join true 2023-11-19 16:10:38 -06:00
root
36d7745289 keeping log folder 2023-11-18 17:29:41 -06:00
root
730f0cdf17 tweak 2023-11-17 11:24:07 -06:00
root
408b491ba1 changed terminal printout 2023-11-17 11:18:44 -06:00
root
4780bc887b changed permissions on secret.yaml 2023-11-17 11:16:46 -06:00
root
7a8ef0bd85 healthcheck is too intense 2023-11-17 11:15:07 -06:00
root
5ceae952a1 removed need for .env file 2023-11-17 10:58:21 -06:00
root
070ecf778a errors out if no env file is found 2023-11-17 10:55:31 -06:00
root
588de129eb more volumes mapped 2023-11-17 10:51:40 -06:00
root
d872f005af improved cleanup 2023-11-17 10:51:32 -06:00
7 changed files with 41 additions and 36 deletions

View File

@@ -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
```

View File

@@ -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
View File

View 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

View File

@@ -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

View File

@@ -1,4 +1,5 @@
#!/bin/bash
set -e
SCRIPT_DIR=$(readlink -f $(dirname "${BASH_SOURCE[0]}"))
REPO_DIR=$(dirname $SCRIPT_DIR)

View File

@@ -1,5 +1,4 @@
homeassistant: true
permit_join: true
mqtt:
base_topic: zigbee2mqtt
client_id: Zigbee2MQTT