Skip to content
Snippets Groups Projects
Commit ca0e01e3 authored by KERDREUX Jerome's avatar KERDREUX Jerome
Browse files

Move the docker in another git repo

parent eb3789da
No related branches found
No related tags found
No related merge requests found
services:
zigbee2mqtt:
container_name: z2m
image: koenkk/zigbee2mqtt
restart: unless-stopped
volumes:
- ./z2m/data:/app/data
- /run/udev:/run/udev:ro
ports:
# Frontend port
- 8080:8080
environment:
- TZ=Europe/Paris
devices:
# Make sure this matched your adapter location
- /dev/serial/by-id/usb-ITEAD_SONOFF_Zigbee_3.0_USB_Dongle_Plus_V2_20220811195009-if00:/dev/zigbee
mosquitto:
container_name: mqtt
image: eclipse-mosquitto
restart: unless-stopped
volumes:
- ./mosquitto/config:/mosquitto/config
# - data:/mosquitto/data
# - log:/mosquitto/log
ports:
- 1883:1883
xaal-go:
container_name: xaal-go
build: xaal-go
restart: unless-stopped
stop_grace_period: 2s
network_mode: host
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
FROM golang:latest
ENV LANG=C.UTF-8
# RUN apt-get update && apt-get -y install sudo tmux fish htop micro procps net-tools iproute2 grc inetutils-ping make docker.io jq && rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get -y install sudo docker.io jq && rm -rf /var/lib/apt/lists/*
# RUN useradd -ms /usr/bin/fish xaal
RUN useradd -ms /usr/bin/bash xaal
RUN usermod -aG docker xaal
RUN echo "xaal ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/xaal
USER xaal
WORKDIR /home/xaal
#SHELL ["/usr/bin/fish", "-c"]
COPY ./files/install.sh ./install.sh
RUN ./install.sh && rm install.sh
COPY ./files/run.sh ./run.sh
COPY ./files/tmux.conf ./.tmux.conf
ENTRYPOINT ["./run.sh"]
build:
docker buildx build -t xaal-go:latest .
#!/usr/bin/bash
# Clone
git clone https://gitlab.imt-atlantique.fr/xaal/code/go/z2m ./z2m
# Build
# cd ~/xaal_git && go mod tidy && go build -o dumper ./tools/dumper.go
cd ~/z2m && go mod tidy && go build .
# Prepare env
# TODO: push the xaal.ini directly from files
mkdir ~/.xaal/
#echo xAAL|xaal-keygen|grep "key=" > ~/.xaal/xaal.ini
echo "key=63c1fdd240c5808f485bc537f3e90cb6bcea1ae91f9d434e9edd78157739ede0" > ~/.xaal/xaal.ini
#!/bin/sh
echo "Starting z2m xAAL Gateway"
# use docker to find out the MQTT broker IP. Note that due to docker volume mounted,
# the docker socket is available in the container but only for root user (wrong group)
# so we need to use sudo.
MQTT=$(sudo docker inspect mqtt | jq -r '.[] | .NetworkSettings.Networks[] | .IPAddress')
echo "Found MQTT broker at: $MQTT"
# Run the xAAL gateway
./z2m/z2m -broker $MQTT
# General
set -g default-terminal "screen-256color"
set -s escape-time 10
set -g set-titles on
# windows numbers start at 1
set -g base-index 1
set -g renumber-windows on
#setw -g automatic-rename on
set -g message-command-style fg=blue,bg=black
set -g message-style bg=colour39,fg=white,bold
setw -g mode-style bg=colour39,fg=white,bold
# set -g set-titles-string '#(whoami) :: #h :: #(curl ipecho.net/plain;echo)'
set -g status-justify left
set -g status-interval 10
set -g status-position bottom
set -g status-style bg=colour236
set -g status-left " "
set -g status-left-length 40
set -g status-right-length 50
set -g status-right "#[fg=colour67]#(cat /proc/loadavg|cut -d' ' -f 1) #[fg=white,bg=colour241] #(whoami) #[fg=colour233,bold,bg=colour245] #(hostname) "
#set -g status-right "#[fg=colour67]#(cat /proc/loadavg|cut -d' ' -f 1) #[fg=white,bg=colour241] #(whoami) #[fg=colour233,bold,bg=colour245] #(ip addr show dev eth0 | grep "inet[^6]" | awk '{print $2}') "
setw -g window-status-format ' #W:#I '
setw -g window-status-current-format ' #W:#I '
setw -g window-status-current-style fg=white,bold,bg=colour39
setw -g window-status-style fg=colour39,bg=colour236,bold
# setw -g window-status-bell-style
setw -g window-status-activity-style bold,fg=colour39,bg=colour238
setw -g xterm-keys on
# activity
setw -g monitor-activity on
set -g bell-action none
set -g visual-bell off
set -g visual-silence off
set -g pane-border-status top
set -g pane-border-style fg=colour67
set -g pane-active-border-style fg=colour39
#-------
# Mouse
#-------
# bind-key m set-option -g mouse off \; display 'Mouse: OFF'
# bind-key M set-option -g mouse on \; display 'Mouse: ON'
bind-key m set-option -g mouse \; display 'Switching mouse'
#-----------------
# pane navigation
#-----------------
bind -r C-b select-pane -t :.+ # select next pane
bind-key = set-window-option synchronize-panes \; display 'Switching synchronize'
#-------------------
# window navigation
#-------------------
bind -r C-p previous-window # select previous window
bind -r C-n next-window # select next window
bind Tab choose-window # move to last active window
bind -r k kill-pane
bind -r r source ~/.tmux.conf \; display 'Loaded config file'
new-session
#!/bin/sh
docker run -it --rm xaal-go:latest
homeassistant: false
frontend: true
mqtt:
base_topic: zigbee2mqtt
server: mqtt://mqtt:1883
keepalive: 60
reject_unauthorized: true
version: 4
serial:
adapter: ember
port: /dev/zigbee
class DumpStateExtension {
constructor(zigbee, mqtt, state, publishEntityState, eventBus, settings, logger) {
this.state = state;
this.zigbee = zigbee;
this.logger = logger;
this.mqttBaseTopic = settings.get().mqtt.base_topic;
this.eventBus = eventBus;
this.mqtt = mqtt;
}
start() {
const mqttHandler = (topic, message) => {
if (topic.startsWith(`${this.mqttBaseTopic}/`) && topic.endsWith('/dump')) {
const deviceId = topic.slice(this.mqttBaseTopic.length + 1, -5);
const queriedDeviceState = this.state.state[deviceId];
console.log('Dumping:', { deviceId, });
if (queriedDeviceState) {
this.mqtt.publish(`${deviceId}`, JSON.stringify(queriedDeviceState));
} else {
this.logger.error(`Device with ID ${deviceId} not found.`);
}
}
};
this.eventBus.onMQTTMessagePublished(this, data => mqttHandler(data.topic, data.payload), this.constructor.name);
this.eventBus.onMQTTMessage(this, data => mqttHandler(data.topic, data.message), this.constructor.name);
}
async stop() {
this.eventBus.removeListeners(this.constructor.name);
}
}
module.exports = DumpStateExtension;
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment