From 0599260e319bd7a381490c68e8b5333836533f9e Mon Sep 17 00:00:00 2001 From: Matthew Patrick <64496719+mrpatrick1991@users.noreply.github.com> Date: Mon, 2 Sep 2024 12:18:20 -0600 Subject: [PATCH 1/3] created docker file docker file and entry point script which copies the values in config.template to the container. --- Dockerfile | 19 +++++++++++++++++++ config.template | 50 ------------------------------------------------- entrypoint.sh | 10 ++++++++++ 3 files changed, 29 insertions(+), 50 deletions(-) create mode 100644 Dockerfile create mode 100644 entrypoint.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1e2f567 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM python:3.10-slim +ENV PYTHONUNBUFFERED=1 + +RUN apt-get update && apt-get install -y gettext && rm -rf /var/lib/apt/lists/* + + +WORKDIR /app +COPY . /app +COPY requirements.txt . + +RUN pip install -r requirements.txt +COPY . . + +COPY config.template /app/config.ini + +COPY entrypoint.sh /app/entrypoint.sh + +RUN chmod +x /app/entrypoint.sh +ENTRYPOINT ["/app/entrypoint.sh"] diff --git a/config.template b/config.template index 777218a..cdcffad 100644 --- a/config.template +++ b/config.template @@ -1,109 +1,59 @@ -#config.ini -# type can be serial, tcp, or ble -# port is the serial port to use, commented out will try to auto-detect -# hostname is the IP address of the device to connect to for tcp type -# mac is the MAC address of the device to connect to for ble type - [interface] type = serial port = /dev/ttyACM0 -# port = /dev/ttyUSB0 -# port = COM1 -# hostname = 192.168.0.1 -# mac = 00:11:22:33:44:55 -# Additional interface for dual radio support [interface2] enabled = False type = serial port = /dev/ttyUSB0 -#port = /dev/ttyACM1 -# port = COM1 -# hostname = meshtastic.local -# mac = 00:11:22:33:44:55 [general] -# if False will respond on all channels but the default channel respond_by_dm_only = True -# defaultChannel is the meshtastic default public channel defaultChannel = 0 -# motd is reset to this value on boot motd = Thanks for using MeshBOT! Have a good day! welcome_message = MeshBot, here for you like a friend who is not. Try sending: ping @foo or, cmd -# enable or disable the Joke module DadJokes = True -# enable or disable the Solar module spaceWeather = True -# enable or disable the wikipedia search module wikipedia = True -# Enable ollama LLM see more at https://ollama.com ollama = False -# Ollama model to use ollamaModel = llama3.1 -# StoreForward Enabled and Limits StoreForward = True StoreLimit = 3 -# 24 hour clock zuluTime = False -# wait time for URL requests urlTimeout = 10 -# logging to file of the non Bot messages LogMessagesToFile = False -# Logging of system messages to file SyslogToFile = False [sentry] -# detect anyone close to the bot SentryEnabled = True -# radius in meters to detect someone close to the bot SentryRadius = 100 -# channel to send a message to when the watchdog is triggered SentryChannel = 9 -# holdoff time multiplied by seconds(20) of the watchdog SentryHoldoff = 9 -# list of ignored nodes numbers ex: 2813308004,4258675309 sentryIgnoreList = [bbs] enabled = True -# list of banned nodes numbers ex: 2813308004,4258675309 bbs_ban_list = -# list of admin nodes numbers ex: 2813308004,4258675309 bbs_admin_list = -# location module [location] enabled = True lat = 48.50 lon = -123.0 -# NOAA weather forecast days, the first two rows are today and tonight NOAAforecastDuration = 4 -# number of weather alerts to display NOAAalertCount = 2 -# use Open-Meteo API for weather data not NOAA useful for non US locations UseMeteoWxAPI = False -# Default to metric units rather than imperial useMetric = False -# repeater module [repeater] enabled = False -# list of repeater channels ex: 2,3 which will be consumed -# and rebroadcasted on the same channel on the other device/node/interface -# with great power comes great responsibility, danger could be lurking in use of this feature -# if you have the two nodes on the same radio configurations, you could create a feedback loop repeater_channels = [radioMon] -# using Hamlib rig control will monitor and alert on channel use enabled = False rigControlServerAddress = localhost:4532 -# broadcast to all nodes on the channel can alsp be = 2,3 sigWatchBroadcastCh = 2 -# minimum SNR as reported by radio via hamlib signalDetectionThreshold = -10 -# hold time for high SNR signalHoldTime = 10 -# the following are combined to reset the monitor signalCooldown = 5 signalCycleLimit = 5 diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..79bafee --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +# Substitute environment variables in the config file +envsubst < /app/config.template > /app/config.ini + +# Debug: Output the generated config file +echo "Generated config.ini:" +cat /app/config.ini + +exec python /app/mesh_bot.py \ No newline at end of file From 78b1cf4af53b98ed27df96195c066474e278691a Mon Sep 17 00:00:00 2001 From: Matthew Patrick <64496719+mrpatrick1991@users.noreply.github.com> Date: Mon, 2 Sep 2024 12:35:44 -0600 Subject: [PATCH 2/3] edit docs and make dockerfile use config.ini not config.template --- Dockerfile | 3 +-- README.md | 5 +++++ entrypoint.sh | 6 +----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1e2f567..0e8f1d9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,8 +11,7 @@ COPY requirements.txt . RUN pip install -r requirements.txt COPY . . -COPY config.template /app/config.ini - +COPY config.ini /app/config.ini COPY entrypoint.sh /app/entrypoint.sh RUN chmod +x /app/entrypoint.sh diff --git a/README.md b/README.md index 5c1f32f..b631e96 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,11 @@ Optionally: - `install.sh` will automate optional venv and requirements installation. - `launch.sh` will activate and launch the app in the venv if built. +For Docker: +- `git clone https://github.com/spudgunman/meshing-around` +- `cd meshing-around && docker build -t meshing-around` +- `docker run meshing-around` + ### Configurations Copy the [config.template](config.template) to `config.ini` and set the appropriate interface for your method (serial/ble/tcp). While BLE and TCP will work, they are not as reliable as serial connections. There is a watchdog to reconnect tcp if possible. To get BLE mac `meshtastic --ble-scan` **NOTE** I have only tested with a single BLE device and the code is written to only have one interface be a BLE port diff --git a/entrypoint.sh b/entrypoint.sh index 79bafee..86701b7 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,10 +1,6 @@ #!/bin/bash # Substitute environment variables in the config file -envsubst < /app/config.template > /app/config.ini - -# Debug: Output the generated config file -echo "Generated config.ini:" -cat /app/config.ini +envsubst < /app/config.ini > /app/config.tmp && mv /app/config.tmp /app/config.ini exec python /app/mesh_bot.py \ No newline at end of file From ee13401b5a4b156cc61c22f8268e8c8b25306089 Mon Sep 17 00:00:00 2001 From: Matthew Patrick <64496719+mrpatrick1991@users.noreply.github.com> Date: Mon, 2 Sep 2024 12:37:30 -0600 Subject: [PATCH 3/3] Update config.template reset to be identical to main branch --- config.template | 54 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/config.template b/config.template index cdcffad..1d4c769 100644 --- a/config.template +++ b/config.template @@ -1,59 +1,109 @@ +#config.ini +# type can be serial, tcp, or ble +# port is the serial port to use, commented out will try to auto-detect +# hostname is the IP address of the device to connect to for tcp type +# mac is the MAC address of the device to connect to for ble type + [interface] type = serial port = /dev/ttyACM0 +# port = /dev/ttyUSB0 +# port = COM1 +# hostname = 192.168.0.1 +# mac = 00:11:22:33:44:55 +# Additional interface for dual radio support [interface2] enabled = False type = serial port = /dev/ttyUSB0 +#port = /dev/ttyACM1 +# port = COM1 +# hostname = meshtastic.local +# mac = 00:11:22:33:44:55 [general] +# if False will respond on all channels but the default channel respond_by_dm_only = True +# defaultChannel is the meshtastic default public channel defaultChannel = 0 +# motd is reset to this value on boot motd = Thanks for using MeshBOT! Have a good day! welcome_message = MeshBot, here for you like a friend who is not. Try sending: ping @foo or, cmd +# enable or disable the Joke module DadJokes = True +# enable or disable the Solar module spaceWeather = True +# enable or disable the wikipedia search module wikipedia = True +# Enable ollama LLM see more at https://ollama.com ollama = False -ollamaModel = llama3.1 +# Ollama model to use (defaults to gemma2:2b) +# ollamaModel = llama3.1 +# StoreForward Enabled and Limits StoreForward = True StoreLimit = 3 +# 24 hour clock zuluTime = False +# wait time for URL requests urlTimeout = 10 +# logging to file of the non Bot messages LogMessagesToFile = False +# Logging of system messages to file SyslogToFile = False [sentry] +# detect anyone close to the bot SentryEnabled = True +# radius in meters to detect someone close to the bot SentryRadius = 100 +# channel to send a message to when the watchdog is triggered SentryChannel = 9 +# holdoff time multiplied by seconds(20) of the watchdog SentryHoldoff = 9 +# list of ignored nodes numbers ex: 2813308004,4258675309 sentryIgnoreList = [bbs] enabled = True +# list of banned nodes numbers ex: 2813308004,4258675309 bbs_ban_list = +# list of admin nodes numbers ex: 2813308004,4258675309 bbs_admin_list = +# location module [location] enabled = True lat = 48.50 lon = -123.0 +# NOAA weather forecast days, the first two rows are today and tonight NOAAforecastDuration = 4 +# number of weather alerts to display NOAAalertCount = 2 +# use Open-Meteo API for weather data not NOAA useful for non US locations UseMeteoWxAPI = False +# Default to metric units rather than imperial useMetric = False +# repeater module [repeater] enabled = False +# list of repeater channels ex: 2,3 which will be consumed +# and rebroadcasted on the same channel on the other device/node/interface +# with great power comes great responsibility, danger could be lurking in use of this feature +# if you have the two nodes on the same radio configurations, you could create a feedback loop repeater_channels = [radioMon] +# using Hamlib rig control will monitor and alert on channel use enabled = False rigControlServerAddress = localhost:4532 +# broadcast to all nodes on the channel can alsp be = 2,3 sigWatchBroadcastCh = 2 +# minimum SNR as reported by radio via hamlib signalDetectionThreshold = -10 +# hold time for high SNR signalHoldTime = 10 +# the following are combined to reset the monitor signalCooldown = 5 -signalCycleLimit = 5 +signalCycleLimit = 5 \ No newline at end of file