From ab995f709d9e1fd78fa77c32c4a1dc5cd2bc67a9 Mon Sep 17 00:00:00 2001 From: Dirk Alders Date: Fri, 23 Jun 2023 06:57:22 +0200 Subject: [PATCH] zigbee container adapted to support also sonoff stick --- zigbee/Dockerfile | 13 ------ zigbee/README | 14 +------ zigbee/docker-compose.template | 11 ++--- zigbee/start.sh | 73 ---------------------------------- 4 files changed, 5 insertions(+), 106 deletions(-) delete mode 100644 zigbee/Dockerfile delete mode 100755 zigbee/start.sh diff --git a/zigbee/Dockerfile b/zigbee/Dockerfile deleted file mode 100644 index 71466f4..0000000 --- a/zigbee/Dockerfile +++ /dev/null @@ -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 diff --git a/zigbee/README b/zigbee/README index f79131e..64406f2 100644 --- a/zigbee/README +++ b/zigbee/README @@ -7,22 +7,12 @@ Configuration: * Edit the volumes section, to have a persistant zigbee2mqtt instance at your local filesystem (fist entry is your local filesystem; 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) -* You might want to set differing versions for the needed software: - * The base operating system is defined in the Dockerfile (very top entry) - * The nodejs is defined in the Dockerfile (curl after #INSTALL nodejs) - * The zigbee2mqtt is already defined via the docker-compose.yml + * Start the container (make up && make down), edit the configuration.yaml + in the volume and restart the container (make up && make logs_zigbee) -Installation: -------------- -* Execute make build up logs_zigbee 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 diff --git a/zigbee/docker-compose.template b/zigbee/docker-compose.template index 1c1fafc..0d22834 100644 --- a/zigbee/docker-compose.template +++ b/zigbee/docker-compose.template @@ -3,18 +3,13 @@ zigbee: restart: always - build: zigbee + image: koenkk/zigbee2mqtt:latest container_name: zigbee volumes: - - /opt/zigbee2mqtt:/opt/zigbee2mqtt - environment: - APP_GIT_VERSION: 1.31.2 - #APP_MQTT_SERVER: mqtt_server - #APP_MQTT_USER: mqtt_user - #APP_MQTT_PASSWORD: mqtt_password + - /opt/zigbee/data:/app/data + - /run/udev:/run/udev:ro network_mode: host #privileged: true devices: - /dev/ttyACM0:/dev/ttyACM0 - command: bash -c "/root/start.sh" diff --git a/zigbee/start.sh b/zigbee/start.sh deleted file mode 100755 index ad71106..0000000 --- a/zigbee/start.sh +++ /dev/null @@ -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