kopia lustrzana https://github.com/mate-dev/mmrelaynode
commit
c7f11a1d19
|
@ -0,0 +1 @@
|
||||||
|
docker-compose.yaml
|
17
README.md
17
README.md
|
@ -11,4 +11,19 @@ Feel free to explore the **Meshtastic** project on their website: [https://mesht
|
||||||
git clone https://github.com/mate-dev/mmrelaynode.git
|
git clone https://github.com/mate-dev/mmrelaynode.git
|
||||||
cd mmrelaynode && git submodule update --init
|
cd mmrelaynode && git submodule update --init
|
||||||
docker compose -f "docker-compose.yaml" up -d --build
|
docker compose -f "docker-compose.yaml" up -d --build
|
||||||
```
|
```
|
||||||
|
|
||||||
|
If modifying the scripts, with the containers stopped, use these commands to rebuild them:
|
||||||
|
|
||||||
|
```
|
||||||
|
docker system prune -af
|
||||||
|
docker-compose build --no-cache
|
||||||
|
docker-compose up -d --force-recreate
|
||||||
|
```
|
||||||
|
|
||||||
|
Use the following command to see the output of command_wrapper.py & the MESHTASTIC_COMMAND_X commands:
|
||||||
|
```
|
||||||
|
docker exec -it mmrelaynode-app cat /home/mesh/app/command_output.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
Note: If you have several commands, it may take a few minutes to finish them all.
|
|
@ -1,13 +1,14 @@
|
||||||
FROM python:3.11-slim-bookworm AS app
|
FROM python:3.11-slim-bookworm AS app
|
||||||
LABEL "website"="https://github.com/mate-dev/mmrelaynode"
|
LABEL "website"="https://github.com/mate-dev/mmrelaynode"
|
||||||
RUN groupadd -g 1000 mesh && useradd -ml -u 1000 -g 1000 -s /bin/bash mesh
|
RUN groupadd -g 1000 mesh && useradd -ml -u 1000 -g 1000 -s /bin/bash mesh
|
||||||
|
RUN echo "export PATH=/home/mesh/.local/bin:\$PATH" >> /home/mesh/.bashrc
|
||||||
RUN pip install --upgrade pip -qq
|
RUN pip install --upgrade pip -qq
|
||||||
RUN ln -s /home/mesh/.local/bin/meshtastic /bin/meshtastic
|
RUN ln -s /home/mesh/.local/bin/meshtastic /bin/meshtastic
|
||||||
USER mesh
|
USER mesh
|
||||||
COPY --chown=mesh:mesh meshtastic-matrix-relay /home/mesh/app
|
COPY --chown=mesh:mesh meshtastic-matrix-relay /home/mesh/app
|
||||||
|
COPY --chown=mesh:mesh --chmod=744 entrypoint.sh /usr/local/bin/entrypoint.sh
|
||||||
COPY --chown=mesh:mesh --chmod=744 wait-for-it.sh /home/mesh/.local/bin/wait-for-it.sh
|
COPY --chown=mesh:mesh --chmod=744 wait-for-it.sh /home/mesh/.local/bin/wait-for-it.sh
|
||||||
COPY --chown=mesh:mesh conf_wrapper.py /home/mesh/app/
|
COPY --chown=mesh:mesh conf_wrapper.py /home/mesh/app/
|
||||||
COPY --chown=mesh:mesh command_wrapper.py /home/mesh/app/
|
COPY --chown=mesh:mesh command_wrapper.py /home/mesh/app/
|
||||||
WORKDIR /home/mesh/app
|
WORKDIR /home/mesh/app
|
||||||
RUN pip install -qq -r /home/mesh/app/requirements.txt --no-cache-dir
|
RUN pip install -qq -r /home/mesh/app/requirements.txt --no-cache-dir
|
||||||
RUN echo "export PATH=/home/mesh/.local/bin:\$PATH" >> /home/mesh/.bashrc
|
|
|
@ -2,21 +2,30 @@ import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
def log_to_file(message):
|
||||||
|
with open('/home/mesh/app/command_output.txt', 'a') as f:
|
||||||
|
f.write(message + "\n")
|
||||||
|
|
||||||
def execute_meshtastic_command(options):
|
def execute_meshtastic_command(options):
|
||||||
"""Execute a meshtastic command with the given options."""
|
"""Execute a meshtastic command with the given options."""
|
||||||
command = ["meshtastic", "--set"] + options.split()
|
command = ["meshtastic", "--host", "mmrelaydevice", "--port", "4403"] + options.split()
|
||||||
subprocess.run(command)
|
log_to_file(f"Executing command: {' '.join(command)}")
|
||||||
time.sleep(30) # Pause for 30 seconds
|
result = subprocess.run(command, capture_output=True, text=True)
|
||||||
|
log_to_file("Standard Output:\n" + result.stdout)
|
||||||
|
log_to_file("Standard Error:\n" + result.stderr)
|
||||||
|
time.sleep(1) # Pause for 1 second between commands
|
||||||
|
|
||||||
|
# Print all environment variables at the start
|
||||||
|
log_to_file("All environment variables:\n" + str(os.environ))
|
||||||
|
|
||||||
# Loop through environment variables in sequence
|
# Loop through environment variables in sequence
|
||||||
index = 1
|
index = 1
|
||||||
while True:
|
while True:
|
||||||
command = os.environ.get(f'MESHTASTIC_COMMAND_{index}')
|
command = os.environ.get(f'MESHTASTIC_COMMAND_{index}')
|
||||||
if command:
|
if command:
|
||||||
|
log_to_file(f"Found command variable: MESHTASTIC_COMMAND_{index} with value: {command}")
|
||||||
execute_meshtastic_command(command)
|
execute_meshtastic_command(command)
|
||||||
index += 1
|
index += 1
|
||||||
else:
|
else:
|
||||||
break
|
log_to_file(f"No more MESHTASTIC_COMMAND variables found, ending at index {index-1}.")
|
||||||
|
break
|
||||||
# Finally, run the main Meshtastic process (or whatever process you want to keep the container running)
|
|
||||||
subprocess.run(["meshtastic"])
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
#!/bin/bash
|
||||||
|
printenv
|
||||||
|
/home/mesh/.local/bin/wait-for-it.sh mmrelaydevice:4403 -t 60
|
||||||
|
python3 /home/mesh/app/command_wrapper.py
|
||||||
|
python3 /home/mesh/app/conf_wrapper.py
|
||||||
|
python3 /home/mesh/app/main.py
|
|
@ -13,10 +13,6 @@ services:
|
||||||
networks:
|
networks:
|
||||||
- mesh
|
- mesh
|
||||||
entrypoint: ["sh", "-c", "meshtasticd"]
|
entrypoint: ["sh", "-c", "meshtasticd"]
|
||||||
environment:
|
|
||||||
MESHTASTIC_COMMAND_1: "--set-owner 'LongName' --set-owner-short 'SHRT' --set-url https://meshtastic.org/e/#CgMSAQESDAgBOAFAA0gBUB5oAQ"
|
|
||||||
MESHTASTIC_COMMAND_2: "--set mqtt.enabled true --set mqtt.address mqtt.meshtastic.org --set mqtt.username meshdev --set mqtt.password large4cats"
|
|
||||||
# You can add as many MESHTASTIC_COMMAND_X as you need, they will be executed in order with a 30 second delay between or add all your setup in one command.
|
|
||||||
|
|
||||||
mmrelayapp:
|
mmrelayapp:
|
||||||
build: app
|
build: app
|
||||||
|
@ -24,19 +20,19 @@ services:
|
||||||
container_name: mmrelaynode-app
|
container_name: mmrelaynode-app
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
depends_on:
|
depends_on:
|
||||||
- mmrelaynode
|
- mmrelayapp
|
||||||
volumes:
|
volumes:
|
||||||
- mesh:/home/mesh
|
- mesh:/home/mesh
|
||||||
networks:
|
networks:
|
||||||
- mesh
|
- mesh
|
||||||
entrypoint: [ "sh", "-c", "/home/mesh/.local/bin/wait-for-it.sh mmrelaynode:4403 -t 60 && python3 command_wrapper.py && python3 conf_wrapper.py && python3 main.py" ]
|
entrypoint: [ "bash", "-c", "entrypoint.sh" ]
|
||||||
environment:
|
environment:
|
||||||
MATRIX_HOMESERVER: "https://example.matrix.org"
|
MATRIX_HOMESERVER: "https://example.matrix.org"
|
||||||
MATRIX_ACCESS_TOKEN: "your_access_token"
|
MATRIX_ACCESS_TOKEN: "your_access_token"
|
||||||
MATRIX_BOT_USER_ID: "@botuser:example.matrix.org"
|
MATRIX_BOT_USER_ID: "@botuser:example.matrix.org"
|
||||||
MESHTASTIC_CONNECTION_TYPE: "network" # "serial" or "network"
|
MESHTASTIC_CONNECTION_TYPE: "network" # "serial" or "network"
|
||||||
MESHTASTIC_SERIAL_PORT: "/dev/ttyUSB0"
|
MESHTASTIC_SERIAL_PORT: "/dev/ttyUSB0"
|
||||||
MESHTASTIC_HOST: "mmrelaynode"
|
MESHTASTIC_HOST: "mmrelaydevice"
|
||||||
MESHTASTIC_MESHNET_NAME: "Your Meshnet Name"
|
MESHTASTIC_MESHNET_NAME: "Your Meshnet Name"
|
||||||
MESHTASTIC_BROADCAST_ENABLED: "true"
|
MESHTASTIC_BROADCAST_ENABLED: "true"
|
||||||
LOGGING_LEVEL: "info"
|
LOGGING_LEVEL: "info"
|
||||||
|
@ -45,27 +41,19 @@ services:
|
||||||
MATRIX_ROOMS_MESHTASTIC_CHANNEL_1: "0"
|
MATRIX_ROOMS_MESHTASTIC_CHANNEL_1: "0"
|
||||||
# MATRIX_ROOMS_ID_2: "#someroomalias2:example.matrix.org"
|
# MATRIX_ROOMS_ID_2: "#someroomalias2:example.matrix.org"
|
||||||
# MATRIX_ROOMS_MESHTASTIC_CHANNEL_2: "1"
|
# MATRIX_ROOMS_MESHTASTIC_CHANNEL_2: "1"
|
||||||
# MATRIX_ROOMS_ID_3: "#someroomalias3:example.matrix.org"
|
|
||||||
# MATRIX_ROOMS_MESHTASTIC_CHANNEL_3: "2"
|
|
||||||
# MATRIX_ROOMS_ID_4: "#someroomalias4:example.matrix.org"
|
|
||||||
# MATRIX_ROOMS_MESHTASTIC_CHANNEL_4: "3"
|
|
||||||
# MATRIX_ROOMS_ID_5: "#someroomalias5:example.matrix.org"
|
|
||||||
# MATRIX_ROOMS_MESHTASTIC_CHANNEL_5: "4"
|
|
||||||
# MATRIX_ROOMS_ID_6: "#someroomalias6:example.matrix.org"
|
|
||||||
# MATRIX_ROOMS_MESHTASTIC_CHANNEL_6: "5"
|
|
||||||
# MATRIX_ROOMS_ID_7: "#someroomalias7:example.matrix.org"
|
|
||||||
# MATRIX_ROOMS_MESHTASTIC_CHANNEL_7: "6"
|
|
||||||
# MATRIX_ROOMS_ID_8: "#someroomalias8:example.matrix.org"
|
|
||||||
# MATRIX_ROOMS_MESHTASTIC_CHANNEL_8: "7"
|
|
||||||
|
|
||||||
# Plugin environment variables
|
# Plugin environment variables
|
||||||
# HEALTH_PLUGIN_ACTIVE: "true"
|
# HEALTH_PLUGIN_ACTIVE: "true"
|
||||||
# MAP_PLUGIN_ACTIVE: "true"
|
# MAP_PLUGIN_ACTIVE: "true"
|
||||||
# NODES_PLUGIN_ACTIVE: "true"
|
# NODES_PLUGIN_ACTIVE: "true"
|
||||||
|
MESHTASTIC_COMMAND_1: "--set-owner 'LongName' --set-owner-short 'SHRT' --set-url https://meshtastic.org/e/#CgMSAQESDAgBOAFAA0gBUB5oAQ"
|
||||||
|
MESHTASTIC_COMMAND_2: "--set mqtt.enabled true --set mqtt.address mqtt.meshtastic.org --set mqtt.username meshdev --set mqtt.password large4cats"
|
||||||
|
MESHTASTIC_COMMAND_3: "--ch-set uplink_enabled true --ch-set downlink_enabled true --ch-index 0"
|
||||||
|
# You can add as many MESHTASTIC_COMMAND_X as you need, they will be executed in order
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
mesh:
|
mesh:
|
||||||
driver: bridge
|
driver: bridge
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
mesh:
|
mesh:
|
Ładowanie…
Reference in New Issue