zigbee container adapted to support also sonoff stick
This commit is contained in:
parent
43ddb30906
commit
ab995f709d
@ -1,13 +0,0 @@
|
|||||||
FROM debian:bookworm
|
|
||||||
RUN apt update
|
|
||||||
RUN apt upgrade -y
|
|
||||||
RUN apt install curl git -y
|
|
||||||
# INSTALL nodejs
|
|
||||||
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
|
|
||||||
RUN apt install nodejs -y
|
|
||||||
# INSTALL yarn
|
|
||||||
RUN curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | tee /usr/share/keyrings/yarnkey.gpg >/dev/null
|
|
||||||
RUN echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | tee /etc/apt/sources.list.d/yarn.list
|
|
||||||
RUN apt update
|
|
||||||
RUN apt install yarn -y
|
|
||||||
COPY start.sh /root
|
|
@ -7,22 +7,12 @@ Configuration:
|
|||||||
* Edit the volumes section, to have a persistant zigbee2mqtt instance
|
* Edit the volumes section, to have a persistant zigbee2mqtt instance
|
||||||
at your local filesystem (fist entry is your local filesystem;
|
at your local filesystem (fist entry is your local filesystem;
|
||||||
leave the second entry ontouched)
|
leave the second entry ontouched)
|
||||||
* Edit the environment variable of the added service, if you need to
|
|
||||||
create a zigbee2mqtt instance or
|
|
||||||
delete the variables, if you want to run an existing instance.
|
|
||||||
* Check and edit (if needed) the device section (first entry is your host filesystem)
|
* Check and edit (if needed) the device section (first entry is your host filesystem)
|
||||||
* You might want to set differing versions for the needed software:
|
* Start the container (make up && make down), edit the configuration.yaml
|
||||||
* The base operating system is defined in the Dockerfile (very top entry)
|
in the volume and restart the container (make up && make logs_zigbee)
|
||||||
* The nodejs is defined in the Dockerfile (curl after #INSTALL nodejs)
|
|
||||||
* The zigbee2mqtt is already defined via the docker-compose.yml
|
|
||||||
|
|
||||||
Installation:
|
|
||||||
-------------
|
|
||||||
* Execute make build up logs_zigbee
|
|
||||||
|
|
||||||
Post-Installation actions:
|
Post-Installation actions:
|
||||||
--------------------------
|
--------------------------
|
||||||
* You should remove the environments section espacially the credentials
|
|
||||||
from docker-compose.yml
|
|
||||||
* You should "chmod go-rwx" for ...zigbee2mqtt/data/configuration.yaml
|
* You should "chmod go-rwx" for ...zigbee2mqtt/data/configuration.yaml
|
||||||
|
|
||||||
|
@ -3,18 +3,13 @@
|
|||||||
|
|
||||||
zigbee:
|
zigbee:
|
||||||
restart: always
|
restart: always
|
||||||
build: zigbee
|
image: koenkk/zigbee2mqtt:latest
|
||||||
container_name: zigbee
|
container_name: zigbee
|
||||||
volumes:
|
volumes:
|
||||||
- /opt/zigbee2mqtt:/opt/zigbee2mqtt
|
- /opt/zigbee/data:/app/data
|
||||||
environment:
|
- /run/udev:/run/udev:ro
|
||||||
APP_GIT_VERSION: 1.31.2
|
|
||||||
#APP_MQTT_SERVER: mqtt_server
|
|
||||||
#APP_MQTT_USER: mqtt_user
|
|
||||||
#APP_MQTT_PASSWORD: mqtt_password
|
|
||||||
network_mode: host
|
network_mode: host
|
||||||
#privileged: true
|
#privileged: true
|
||||||
devices:
|
devices:
|
||||||
- /dev/ttyACM0:/dev/ttyACM0
|
- /dev/ttyACM0:/dev/ttyACM0
|
||||||
command: bash -c "/root/start.sh"
|
|
||||||
|
|
||||||
|
@ -1,73 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
|
|
||||||
APP_TARGET_PATH=/opt/zigbee2mqtt
|
|
||||||
|
|
||||||
my_print()
|
|
||||||
{
|
|
||||||
echo `date` $HOST [$$]: $1
|
|
||||||
}
|
|
||||||
|
|
||||||
fail_loop()
|
|
||||||
{
|
|
||||||
my_print "Start script failed..."
|
|
||||||
for (( ; ; ))
|
|
||||||
do
|
|
||||||
sleep 60
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
check_environment()
|
|
||||||
{
|
|
||||||
fail=0
|
|
||||||
# returns 0 if environment is not okay
|
|
||||||
if [[ -z $APP_GIT_VERSION ]]; then
|
|
||||||
my_print "Environment variable APP_GIT_VERSION does not exist!"
|
|
||||||
fail=1
|
|
||||||
fi
|
|
||||||
if [[ -z $APP_MQTT_SERVER ]]; then
|
|
||||||
my_print "Environment variable APP_MQTT_SERVER does not exist!"
|
|
||||||
fail=1
|
|
||||||
fi
|
|
||||||
#
|
|
||||||
if [[ $fail -ne 0 ]]; then
|
|
||||||
fail_loop
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if [[ ! -d $APP_TARGET_PATH ]]; then
|
|
||||||
my_print "Directory \"$APP_TARGET_PATH\" does not exist."
|
|
||||||
fi
|
|
||||||
if [[ ! -d $APP_TARGET_PATH/.git ]]; then
|
|
||||||
check_environment
|
|
||||||
my_print "Cloning zigbee2mqtt repository..."
|
|
||||||
git clone https://github.com/Koenkk/zigbee2mqtt.git $APP_TARGET_PATH
|
|
||||||
my_print "Changing to directory $APP_TARGET_PAT"
|
|
||||||
cd $APP_TARGET_PATH
|
|
||||||
my_print "Changing to git version $APP_GIT_VERSION"
|
|
||||||
git checkout $APP_GIT_VERSION
|
|
||||||
my_print "Replacing MQTT servername in $APP_TARGET_PATH/data/configuration.yaml"
|
|
||||||
sed -i "s|mqtt://localhost|mqtt://$APP_MQTT_SERVER|g" $APP_TARGET_PATH/data/configuration.yaml
|
|
||||||
if [[ ! -z $APP_MQTT_USER ]]; then
|
|
||||||
my_print "Adding MQTT username in $APP_TARGET_PATH/data/configuration.yaml"
|
|
||||||
sed -i "s|# user: my_user|user: $APP_MQTT_USER|g" $APP_TARGET_PATH/data/configuration.yaml
|
|
||||||
fi
|
|
||||||
if [[ ! -z $APP_MQTT_PASSWORD ]]; then
|
|
||||||
my_print "Adding MQTT password in $APP_TARGET_PATH/data/configuration.yaml"
|
|
||||||
sed -i "s|# password: my_password|password: $APP_MQTT_PASSWORD|g" $APP_TARGET_PATH/data/configuration.yaml
|
|
||||||
fi
|
|
||||||
my_print "Preparing application (npm ci)"
|
|
||||||
npm ci
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd $APP_TARGET_PATH
|
|
||||||
my_print "Starting zigbee2mqtt..."
|
|
||||||
npm start
|
|
||||||
|
|
||||||
my_print "**********************************************************"
|
|
||||||
my_print "* Start of zigbee2mqtt failed. *"
|
|
||||||
my_print "* Check running npm ci and npm start in /opt/zigbee2mqtt *"
|
|
||||||
my_print "**********************************************************"
|
|
||||||
fail_loop
|
|
Loading…
x
Reference in New Issue
Block a user