Переглянути джерело

zigbee container adapted to support also sonoff stick

master
Dirk Alders 1 рік тому
джерело
коміт
ab995f709d
4 змінених файлів з 5 додано та 106 видалено
  1. 0
    13
      zigbee/Dockerfile
  2. 2
    12
      zigbee/README
  3. 3
    8
      zigbee/docker-compose.template
  4. 0
    73
      zigbee/start.sh

+ 0
- 13
zigbee/Dockerfile Переглянути файл

@@ -1,13 +0,0 @@
1
-FROM debian:bookworm
2
-RUN apt update
3
-RUN apt upgrade -y
4
-RUN apt install curl git -y
5
-# INSTALL nodejs
6
-RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
7
-RUN apt install nodejs -y
8
-# INSTALL yarn
9
-RUN curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | tee /usr/share/keyrings/yarnkey.gpg >/dev/null
10
-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
11
-RUN apt update
12
-RUN apt install yarn -y
13
-COPY start.sh /root

+ 2
- 12
zigbee/README Переглянути файл

@@ -7,22 +7,12 @@ Configuration:
7 7
   * Edit the volumes section, to have a persistant zigbee2mqtt instance
8 8
     at your local filesystem (fist entry is your local filesystem;
9 9
     leave the second entry ontouched)
10
-  * Edit the environment variable of the added service, if you need to
11
-    create a zigbee2mqtt instance or 
12
-    delete the variables, if you want to run an existing instance.
13 10
   * Check and edit (if needed) the device section  (first entry is your host filesystem)
14
-* You might want to set differing versions for the needed software:
15
-  * The base operating system is defined in the Dockerfile (very top entry)
16
-  * The nodejs is defined in the Dockerfile (curl after #INSTALL nodejs)
17
-  * The zigbee2mqtt is already defined via the docker-compose.yml
11
+  * Start the container (make up && make down), edit the configuration.yaml 
12
+    in the volume and restart the container (make up && make logs_zigbee)
18 13
 
19
-Installation:
20
--------------
21
-* Execute make build up logs_zigbee
22 14
 
23 15
 Post-Installation actions:
24 16
 --------------------------
25
-* You should remove the environments section espacially the credentials
26
-  from docker-compose.yml
27 17
 * You should "chmod go-rwx" for ...zigbee2mqtt/data/configuration.yaml
28 18
 

+ 3
- 8
zigbee/docker-compose.template Переглянути файл

@@ -3,18 +3,13 @@
3 3
 
4 4
   zigbee:
5 5
     restart: always
6
-    build: zigbee
6
+    image: koenkk/zigbee2mqtt:latest
7 7
     container_name: zigbee
8 8
     volumes:
9
-      - /opt/zigbee2mqtt:/opt/zigbee2mqtt
10
-    environment:
11
-      APP_GIT_VERSION: 1.31.2
12
-      #APP_MQTT_SERVER: mqtt_server
13
-      #APP_MQTT_USER: mqtt_user
14
-      #APP_MQTT_PASSWORD: mqtt_password
9
+      - /opt/zigbee/data:/app/data
10
+      - /run/udev:/run/udev:ro
15 11
     network_mode: host
16 12
     #privileged: true
17 13
     devices:
18 14
       - /dev/ttyACM0:/dev/ttyACM0
19
-    command: bash -c "/root/start.sh"
20 15
 

+ 0
- 73
zigbee/start.sh Переглянути файл

@@ -1,73 +0,0 @@
1
-#!/bin/bash
2
-#
3
-
4
-APP_TARGET_PATH=/opt/zigbee2mqtt
5
-
6
-my_print()
7
-{
8
-    echo `date` $HOST [$$]: $1
9
-}
10
-
11
-fail_loop()
12
-{
13
-    my_print "Start script failed..."
14
-    for (( ; ; ))
15
-    do
16
-        sleep 60
17
-    done
18
-}
19
-
20
-check_environment()
21
-{
22
-    fail=0
23
-    # returns 0 if environment is not okay
24
-    if [[ -z $APP_GIT_VERSION ]]; then
25
-        my_print "Environment variable APP_GIT_VERSION does not exist!"
26
-        fail=1
27
-    fi
28
-    if [[ -z $APP_MQTT_SERVER ]]; then
29
-        my_print "Environment variable APP_MQTT_SERVER does not exist!"
30
-        fail=1
31
-    fi
32
-    #
33
-    if [[ $fail -ne 0 ]]; then
34
-        fail_loop
35
-    fi
36
-}
37
-
38
-
39
-
40
-if [[ ! -d $APP_TARGET_PATH ]]; then
41
-    my_print "Directory \"$APP_TARGET_PATH\" does not exist."
42
-fi
43
-if [[ ! -d $APP_TARGET_PATH/.git ]]; then
44
-    check_environment
45
-    my_print "Cloning zigbee2mqtt repository..."
46
-    git clone https://github.com/Koenkk/zigbee2mqtt.git $APP_TARGET_PATH
47
-    my_print "Changing to directory $APP_TARGET_PAT"
48
-    cd $APP_TARGET_PATH
49
-    my_print "Changing to git version $APP_GIT_VERSION"
50
-    git checkout $APP_GIT_VERSION
51
-    my_print "Replacing MQTT servername in $APP_TARGET_PATH/data/configuration.yaml"
52
-    sed -i "s|mqtt://localhost|mqtt://$APP_MQTT_SERVER|g" $APP_TARGET_PATH/data/configuration.yaml
53
-    if [[ ! -z $APP_MQTT_USER ]]; then
54
-        my_print "Adding MQTT username in $APP_TARGET_PATH/data/configuration.yaml"
55
-        sed -i "s|# user: my_user|user: $APP_MQTT_USER|g" $APP_TARGET_PATH/data/configuration.yaml
56
-    fi
57
-    if [[ ! -z $APP_MQTT_PASSWORD ]]; then
58
-        my_print "Adding MQTT password in $APP_TARGET_PATH/data/configuration.yaml"
59
-        sed -i "s|# password: my_password|password: $APP_MQTT_PASSWORD|g" $APP_TARGET_PATH/data/configuration.yaml
60
-    fi
61
-    my_print "Preparing application (npm ci)"
62
-    npm ci
63
-fi
64
-
65
-cd $APP_TARGET_PATH
66
-my_print "Starting zigbee2mqtt..."
67
-npm start
68
-
69
-my_print "**********************************************************"
70
-my_print "* Start of zigbee2mqtt failed.                           *"
71
-my_print "* Check running npm ci and npm start in /opt/zigbee2mqtt *"
72
-my_print "**********************************************************"
73
-fail_loop

Завантаження…
Відмінити
Зберегти