From 0536657c8ee0dbb9dbe2ee0d2f5d44eb0d280853 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Mon, 23 Dec 2024 12:52:17 -0800 Subject: [PATCH 01/68] Update config.template --- config.template | 1 + 1 file changed, 1 insertion(+) diff --git a/config.template b/config.template index 430a093..0442a2f 100644 --- a/config.template +++ b/config.template @@ -188,6 +188,7 @@ enable_read_news = False news_file_path = news.txt # only return a single random line from the news file news_random_line = False +# enable the use of exernal shell commands enable_runShellCmd = False [smtp] From 180a8261ca0fab2c50f381177dd6a95b56569232 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Mon, 23 Dec 2024 12:55:29 -0800 Subject: [PATCH 02/68] enhance --- mesh_bot.py | 2 +- runShell.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mesh_bot.py b/mesh_bot.py index 52d9c52..911b69a 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -770,7 +770,7 @@ def sysinfo(message, message_from_id, deviceID): return "sysinfo command returns system information." else: if enable_runShellCmd and file_monitor_enabled: - shellData = call_external_script(message) + shellData = call_external_script(message).rstrip() return get_sysinfo(message_from_id, deviceID) + "\n" + shellData else: return get_sysinfo(message_from_id, deviceID) diff --git a/runShell.sh b/runShell.sh index c626bde..c993750 100644 --- a/runShell.sh +++ b/runShell.sh @@ -9,7 +9,7 @@ free_space=$(df -h | grep ' /$' | awk '{print $4}') cpu_usage=$(top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1}') ram_usage=$(free | grep Mem | awk '{print $3/$2 * 100.0}') -# if command vcgencmd is found +# if command vcgencmd is found, part of raspberrypi tools, use it to get temperature if command -v vcgencmd &> /dev/null then # get temperature @@ -17,11 +17,11 @@ then # temp in fahrenheit tempf=$(echo "scale=2; $temp * 9 / 5 + 32" | bc) else + # get temperature from thermal zone temp=$(paste <(cat /sys/class/thermal/thermal_zone*/type) <(cat /sys/class/thermal/thermal_zone*/temp) | grep "temp" | awk '{print $2/1000}' | awk '{s+=$1} END {print s/NR}') tempf=$(echo "scale=2; $temp * 9 / 5 + 32" | bc) fi - # print telemetry data printf "Free Space: %s\n" "$free_space" printf "CPU Usage: %.1f%%\n" "$cpu_usage" From 9a380964aa93c600938c9cea214c2b2295204e1c Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Mon, 23 Dec 2024 13:09:46 -0800 Subject: [PATCH 03/68] Update runShell.sh --- runShell.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/runShell.sh b/runShell.sh index c993750..9a3cacf 100644 --- a/runShell.sh +++ b/runShell.sh @@ -23,7 +23,4 @@ else fi # print telemetry data -printf "Free Space: %s\n" "$free_space" -printf "CPU Usage: %.1f%%\n" "$cpu_usage" -printf "RAM Usage: %.2f%%\n" "$ram_usage" -printf "Temperature: %.1f°C (%.1f°F)\n" "$temp" "$tempf" \ No newline at end of file +printf "Disk: %s\n" "$free_space CPU%: %.1f%%\n" "$cpu_usage RAM: %.2f%%\n" "$ram_usage CPU: %.1f°C (%.1f°F)\n" "$temp" "$tempf" \ No newline at end of file From f32ceb0383a0ce2c7e5930a6e91004c1f2136d74 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Mon, 23 Dec 2024 13:11:09 -0800 Subject: [PATCH 04/68] Update runShell.sh --- runShell.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/runShell.sh b/runShell.sh index 9a3cacf..1f1f323 100644 --- a/runShell.sh +++ b/runShell.sh @@ -23,4 +23,7 @@ else fi # print telemetry data -printf "Disk: %s\n" "$free_space CPU%: %.1f%%\n" "$cpu_usage RAM: %.2f%%\n" "$ram_usage CPU: %.1f°C (%.1f°F)\n" "$temp" "$tempf" \ No newline at end of file +printf "Disk: %s" "$free_space" +printf "RAM: %.2f%%" "$ram_usage" +printf "CPU: %.1f%%" "$cpu_usage" +printf "CPU-T: %.1f°C (%.1f°F)" "$temp" "$tempf" \ No newline at end of file From 8861179cb2c7b6666dff932e1e06a2880d4531a1 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Mon, 23 Dec 2024 13:11:47 -0800 Subject: [PATCH 05/68] Update runShell.sh --- runShell.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/runShell.sh b/runShell.sh index 1f1f323..2328f0c 100644 --- a/runShell.sh +++ b/runShell.sh @@ -24,6 +24,6 @@ fi # print telemetry data printf "Disk: %s" "$free_space" -printf "RAM: %.2f%%" "$ram_usage" -printf "CPU: %.1f%%" "$cpu_usage" -printf "CPU-T: %.1f°C (%.1f°F)" "$temp" "$tempf" \ No newline at end of file +printf " RAM: %.2f%%" "$ram_usage" +printf " CPU: %.1f%%" "$cpu_usage" +printf " CPU-T: %.1f°C (%.1f°F)" "$temp" "$tempf" \ No newline at end of file From afa41c6ecd814a6de3ae51574ccc8b69bd7afa79 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Mon, 23 Dec 2024 13:12:06 -0800 Subject: [PATCH 06/68] Update runShell.sh --- runShell.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/runShell.sh b/runShell.sh index 2328f0c..7785d59 100644 --- a/runShell.sh +++ b/runShell.sh @@ -23,7 +23,7 @@ else fi # print telemetry data -printf "Disk: %s" "$free_space" -printf " RAM: %.2f%%" "$ram_usage" -printf " CPU: %.1f%%" "$cpu_usage" -printf " CPU-T: %.1f°C (%.1f°F)" "$temp" "$tempf" \ No newline at end of file +printf "Disk:%s" "$free_space" +printf " RAM:%.2f%%" "$ram_usage" +printf " CPU:%.1f%%" "$cpu_usage" +printf " CPU-T:%.1f°C (%.1f°F)" "$temp" "$tempf" \ No newline at end of file From 49c098ef0b4a5f5b589b6ecff1ac0866c40acec3 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Mon, 23 Dec 2024 13:15:53 -0800 Subject: [PATCH 07/68] Update filemon.py --- modules/filemon.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/filemon.py b/modules/filemon.py index 4bec6fd..1ea8fda 100644 --- a/modules/filemon.py +++ b/modules/filemon.py @@ -72,7 +72,7 @@ def call_external_script(message, script="runShell.sh"): if not os.path.exists(script_path): logger.warning(f"FileMon: Script not found: {script_path}") return "sorry I can't do that" - output = os.popen(f"bash {script_path} {message}").read() + output = os.popen(f"bash {script_path}").read() return output except Exception as e: logger.warning(f"FileMon: Error calling external script: {e}") From 30d2b996c02e310ee3634a347be52afe35438f4c Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Mon, 23 Dec 2024 13:16:11 -0800 Subject: [PATCH 08/68] Update filemon.py --- modules/filemon.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/filemon.py b/modules/filemon.py index 1ea8fda..4bec6fd 100644 --- a/modules/filemon.py +++ b/modules/filemon.py @@ -72,7 +72,7 @@ def call_external_script(message, script="runShell.sh"): if not os.path.exists(script_path): logger.warning(f"FileMon: Script not found: {script_path}") return "sorry I can't do that" - output = os.popen(f"bash {script_path}").read() + output = os.popen(f"bash {script_path} {message}").read() return output except Exception as e: logger.warning(f"FileMon: Error calling external script: {e}") From 7ffa9d530968da84915409a87de00c64d4f7f730 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Mon, 23 Dec 2024 13:17:06 -0800 Subject: [PATCH 09/68] Update mesh_bot.py --- mesh_bot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mesh_bot.py b/mesh_bot.py index 911b69a..7eadf01 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -770,7 +770,7 @@ def sysinfo(message, message_from_id, deviceID): return "sysinfo command returns system information." else: if enable_runShellCmd and file_monitor_enabled: - shellData = call_external_script(message).rstrip() + shellData = call_external_script(None).rstrip() return get_sysinfo(message_from_id, deviceID) + "\n" + shellData else: return get_sysinfo(message_from_id, deviceID) From 9cc8dd7143308c23282ff48853ba38b73aa13d12 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Mon, 23 Dec 2024 16:36:33 -0800 Subject: [PATCH 10/68] Update runShell.sh --- runShell.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/runShell.sh b/runShell.sh index 7785d59..5dfc5a7 100644 --- a/runShell.sh +++ b/runShell.sh @@ -8,6 +8,7 @@ program_path=$(pwd) free_space=$(df -h | grep ' /$' | awk '{print $4}') cpu_usage=$(top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1}') ram_usage=$(free | grep Mem | awk '{print $3/$2 * 100.0}') +ram_free=$(echo "scale=2; 100 - $ram_usage" | bc) # if command vcgencmd is found, part of raspberrypi tools, use it to get temperature if command -v vcgencmd &> /dev/null From 3fae42305c79fa021cf20aee73938cd89cb5a451 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Mon, 23 Dec 2024 18:56:05 -0800 Subject: [PATCH 11/68] sysEnv enhance --- mesh_bot.py | 2 +- modules/filemon.py | 8 ++++++-- runShell.sh | 25 +------------------------ sysEnv.sh | 30 ++++++++++++++++++++++++++++++ 4 files changed, 38 insertions(+), 27 deletions(-) create mode 100644 sysEnv.sh diff --git a/mesh_bot.py b/mesh_bot.py index 7eadf01..89a7b3d 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -770,7 +770,7 @@ def sysinfo(message, message_from_id, deviceID): return "sysinfo command returns system information." else: if enable_runShellCmd and file_monitor_enabled: - shellData = call_external_script(None).rstrip() + shellData = call_external_script(None, "sysEnv.sh").rstrip() return get_sysinfo(message_from_id, deviceID) + "\n" + shellData else: return get_sysinfo(message_from_id, deviceID) diff --git a/modules/filemon.py b/modules/filemon.py index 4bec6fd..d309b96 100644 --- a/modules/filemon.py +++ b/modules/filemon.py @@ -70,8 +70,12 @@ def call_external_script(message, script="runShell.sh"): script_path = os.path.join(current_working_directory, script) if not os.path.exists(script_path): - logger.warning(f"FileMon: Script not found: {script_path}") - return "sorry I can't do that" + # try the raw script name + script_path = script + if not os.path.exists(script_path): + logger.warning(f"FileMon: Script not found: {script_path}") + return "sorry I can't do that" + output = os.popen(f"bash {script_path} {message}").read() return output except Exception as e: diff --git a/runShell.sh b/runShell.sh index 5dfc5a7..3e67e7e 100644 --- a/runShell.sh +++ b/runShell.sh @@ -4,27 +4,4 @@ cd "$(dirname "$0")" program_path=$(pwd) -# get basic telemetry data. Free space, CPU, RAM, and temperature for a raspberry pi -free_space=$(df -h | grep ' /$' | awk '{print $4}') -cpu_usage=$(top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1}') -ram_usage=$(free | grep Mem | awk '{print $3/$2 * 100.0}') -ram_free=$(echo "scale=2; 100 - $ram_usage" | bc) - -# if command vcgencmd is found, part of raspberrypi tools, use it to get temperature -if command -v vcgencmd &> /dev/null -then - # get temperature - temp=$(vcgencmd measure_temp | sed "s/temp=//" | sed "s/'C//") - # temp in fahrenheit - tempf=$(echo "scale=2; $temp * 9 / 5 + 32" | bc) -else - # get temperature from thermal zone - temp=$(paste <(cat /sys/class/thermal/thermal_zone*/type) <(cat /sys/class/thermal/thermal_zone*/temp) | grep "temp" | awk '{print $2/1000}' | awk '{s+=$1} END {print s/NR}') - tempf=$(echo "scale=2; $temp * 9 / 5 + 32" | bc) -fi - -# print telemetry data -printf "Disk:%s" "$free_space" -printf " RAM:%.2f%%" "$ram_usage" -printf " CPU:%.1f%%" "$cpu_usage" -printf " CPU-T:%.1f°C (%.1f°F)" "$temp" "$tempf" \ No newline at end of file +printf "Running meshing-around demo script for shell scripting\n" \ No newline at end of file diff --git a/sysEnv.sh b/sysEnv.sh new file mode 100644 index 0000000..69e18f4 --- /dev/null +++ b/sysEnv.sh @@ -0,0 +1,30 @@ +#!/bin/bash +# meshing-around shell script for sysinfo +# runShell.sh +cd "$(dirname "$0")" +program_path=$(pwd) + +# get basic telemetry data. Free space, CPU, RAM, and temperature for a raspberry pi +free_space=$(df -h | grep ' /$' | awk '{print $4}') +cpu_usage=$(top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1}') +ram_usage=$(free | grep Mem | awk '{print $3/$2 * 100.0}') +ram_free=$(echo "scale=2; 100 - $ram_usage" | bc) + +# if command vcgencmd is found, part of raspberrypi tools, use it to get temperature +if command -v vcgencmd &> /dev/null +then + # get temperature + temp=$(vcgencmd measure_temp | sed "s/temp=//" | sed "s/'C//") + # temp in fahrenheit + tempf=$(echo "scale=2; $temp * 9 / 5 + 32" | bc) +else + # get temperature from thermal zone + temp=$(paste <(cat /sys/class/thermal/thermal_zone*/type) <(cat /sys/class/thermal/thermal_zone*/temp) | grep "temp" | awk '{print $2/1000}' | awk '{s+=$1} END {print s/NR}') + tempf=$(echo "scale=2; $temp * 9 / 5 + 32" | bc) +fi + +# print telemetry data +printf "Disk:%s" "$free_space" +printf " RAM:%.2f%%" "$ram_usage" +printf " CPU:%.1f%%" "$cpu_usage" +printf " CPU-T:%.1f°C (%.1f°F)" "$temp" "$tempf" \ No newline at end of file From 26303102107c50cc1f749d836fa7a33a553c4cfa Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Tue, 24 Dec 2024 11:29:54 -0800 Subject: [PATCH 12/68] Update system.py --- modules/system.py | 158 ++++++++++++++++++++++++---------------------- 1 file changed, 81 insertions(+), 77 deletions(-) diff --git a/modules/system.py b/modules/system.py index 84dc77a..2dd6d21 100644 --- a/modules/system.py +++ b/modules/system.py @@ -863,90 +863,94 @@ def displayNodeTelemetry(nodeID=0, rxNode=0, userRequested=False): positionMetadata = {} def consumeMetadata(packet, rxNode=0): - # keep records of recent telemetry data - debugMetadata = False - packet_type = '' - if packet.get('decoded'): - packet_type = packet['decoded']['portnum'] - nodeID = packet['from'] + try: + # keep records of recent telemetry data + debugMetadata = False + packet_type = '' + if packet.get('decoded'): + packet_type = packet['decoded']['portnum'] + nodeID = packet['from'] - # TELEMETRY packets - if packet_type == 'TELEMETRY_APP': - #if debugMetadata: print(f"DEBUG TELEMETRY_APP: {packet}\n\n") - # get the telemetry data - telemetry_packet = packet['decoded']['telemetry'] - if telemetry_packet.get('deviceMetrics'): - deviceMetrics = telemetry_packet['deviceMetrics'] - if telemetry_packet.get('localStats'): - localStats = telemetry_packet['localStats'] - # Check if 'numPacketsTx' and 'numPacketsRx' exist and are not zero - if localStats.get('numPacketsTx') is not None and localStats.get('numPacketsRx') is not None and localStats['numPacketsTx'] != 0: - # Assign the values to the telemetry dictionary - keys = [ - 'numPacketsTx', 'numPacketsRx', 'numOnlineNodes', - 'numOfflineNodes', 'numPacketsTxErr', 'numPacketsRxErr', 'numTotalNodes'] - + # TELEMETRY packets + if packet_type == 'TELEMETRY_APP': + #if debugMetadata: print(f"DEBUG TELEMETRY_APP: {packet}\n\n") + # get the telemetry data + telemetry_packet = packet['decoded']['telemetry'] + if telemetry_packet.get('deviceMetrics'): + deviceMetrics = telemetry_packet['deviceMetrics'] + if telemetry_packet.get('localStats'): + localStats = telemetry_packet['localStats'] + # Check if 'numPacketsTx' and 'numPacketsRx' exist and are not zero + if localStats.get('numPacketsTx') is not None and localStats.get('numPacketsRx') is not None and localStats['numPacketsTx'] != 0: + # Assign the values to the telemetry dictionary + keys = [ + 'numPacketsTx', 'numPacketsRx', 'numOnlineNodes', + 'numOfflineNodes', 'numPacketsTxErr', 'numPacketsRxErr', 'numTotalNodes'] + + for key in keys: + if localStats.get(key) is not None: + telemetryData[rxNode][key] = localStats.get(key) + + # POSITION_APP packets + if packet_type == 'POSITION_APP': + if debugMetadata: print(f"DEBUG POSITION_APP: {packet}\n\n") + # get the position data + keys = ['altitude', 'groundSpeed', 'precisionBits'] + position_data = packet['decoded']['position'] + try: + if nodeID not in positionMetadata: + positionMetadata[nodeID] = {} + for key in keys: - if localStats.get(key) is not None: - telemetryData[rxNode][key] = localStats.get(key) - - # POSITION_APP packets - if packet_type == 'POSITION_APP': - if debugMetadata: print(f"DEBUG POSITION_APP: {packet}\n\n") - # get the position data - keys = ['altitude', 'groundSpeed', 'precisionBits'] - position_data = packet['decoded']['position'] - try: - if nodeID not in positionMetadata: - positionMetadata[nodeID] = {} - - for key in keys: - positionMetadata[nodeID][key] = position_data.get(key, 0) - - # Keep the positionMetadata dictionary at 5 records - if len(positionMetadata) > 20: - # Remove the oldest entry - oldest_nodeID = next(iter(positionMetadata)) - del positionMetadata[oldest_nodeID] - except Exception as e: - logger.debug(f"System: POSITION_APP decode error: {e} packet {packet}") + positionMetadata[nodeID][key] = position_data.get(key, 0) + + # Keep the positionMetadata dictionary at 5 records + if len(positionMetadata) > 20: + # Remove the oldest entry + oldest_nodeID = next(iter(positionMetadata)) + del positionMetadata[oldest_nodeID] + except Exception as e: + logger.debug(f"System: POSITION_APP decode error: {e} packet {packet}") - # WAYPOINT_APP packets - if packet_type == 'WAYPOINT_APP': - if debugMetadata: print(f"DEBUG WAYPOINT_APP: {packet['decoded']['waypoint']}\n\n") - # get the waypoint data - waypoint_data = packet['decoded']['waypoint'] - keys = ['latitude', 'longitude',] + # WAYPOINT_APP packets + if packet_type == 'WAYPOINT_APP': + if debugMetadata: print(f"DEBUG WAYPOINT_APP: {packet['decoded']['waypoint']}\n\n") + # get the waypoint data + waypoint_data = packet['decoded']['waypoint'] + keys = ['latitude', 'longitude',] - # NEIGHBORINFO_APP - if packet_type == 'NEIGHBORINFO_APP': - if debugMetadata: print(f"DEBUG NEIGHBORINFO_APP: {packet}\n\n") - # get the neighbor info data - neighbor_data = packet['decoded']['neighborInfo'] - - # TRACEROUTE_APP - if packet_type == 'TRACEROUTE_APP': - if debugMetadata: print(f"DEBUG TRACEROUTE_APP: {packet}\n\n") - # get the traceroute data - traceroute_data = packet['decoded']['traceroute'] + # NEIGHBORINFO_APP + if packet_type == 'NEIGHBORINFO_APP': + if debugMetadata: print(f"DEBUG NEIGHBORINFO_APP: {packet}\n\n") + # get the neighbor info data + neighbor_data = packet['decoded']['neighborInfo'] + + # TRACEROUTE_APP + if packet_type == 'TRACEROUTE_APP': + if debugMetadata: print(f"DEBUG TRACEROUTE_APP: {packet}\n\n") + # get the traceroute data + traceroute_data = packet['decoded']['traceroute'] - # DETECTION_SENSOR_APP - if packet_type == 'DETECTION_SENSOR_APP': - if debugMetadata: print(f"DEBUG DETECTION_SENSOR_APP: {packet}\n\n") - # get the detection sensor data - detection_data = packet['decoded']['detectionSensor'] + # DETECTION_SENSOR_APP + if packet_type == 'DETECTION_SENSOR_APP': + if debugMetadata: print(f"DEBUG DETECTION_SENSOR_APP: {packet}\n\n") + # get the detection sensor data + detection_data = packet['decoded']['detectionSensor'] - # PAXCOUNTER_APP - if packet_type == 'PAXCOUNTER_APP': - if debugMetadata: print(f"DEBUG PAXCOUNTER_APP: {packet}\n\n") - # get the paxcounter data - paxcounter_data = packet['decoded']['paxcounter'] + # PAXCOUNTER_APP + if packet_type == 'PAXCOUNTER_APP': + if debugMetadata: print(f"DEBUG PAXCOUNTER_APP: {packet}\n\n") + # get the paxcounter data + paxcounter_data = packet['decoded']['paxcounter'] - # REMOTE_HARDWARE_APP - if packet_type == 'REMOTE_HARDWARE_APP': - if debugMetadata: print(f"DEBUG REMOTE_HARDWARE_APP: {packet}\n\n") - # get the remote hardware data - remote_hardware_data = packet['decoded']['remoteHardware'] + # REMOTE_HARDWARE_APP + if packet_type == 'REMOTE_HARDWARE_APP': + if debugMetadata: print(f"DEBUG REMOTE_HARDWARE_APP: {packet}\n\n") + # get the remote hardware data + remote_hardware_data = packet['decoded']['remoteHardware'] + except KeyError as e: + logger.critical(f"System: Error consuming metadata: {e} Device:{rxNode}") + logger.debug(f"System: Error Packet = {packet}") def get_sysinfo(nodeID=0, deviceID=1): # Get the system telemetry data for return on the sysinfo command From 9bc6f6f6617cf77f57cfdf771ded58a7350160ef Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Tue, 24 Dec 2024 12:21:58 -0800 Subject: [PATCH 13/68] Update system.py --- modules/system.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/system.py b/modules/system.py index 2dd6d21..075046e 100644 --- a/modules/system.py +++ b/modules/system.py @@ -12,6 +12,7 @@ import io # for suppressing output on watchdog from modules.log import * # Global Variables +debugMetadata = False # packet debug for non text messages trap_list = ("cmd","cmd?") # default trap list help_message = "Bot CMD?:" asyncLoop = asyncio.new_event_loop() @@ -865,7 +866,6 @@ positionMetadata = {} def consumeMetadata(packet, rxNode=0): try: # keep records of recent telemetry data - debugMetadata = False packet_type = '' if packet.get('decoded'): packet_type = packet['decoded']['portnum'] @@ -873,7 +873,7 @@ def consumeMetadata(packet, rxNode=0): # TELEMETRY packets if packet_type == 'TELEMETRY_APP': - #if debugMetadata: print(f"DEBUG TELEMETRY_APP: {packet}\n\n") + if debugMetadata: print(f"DEBUG TELEMETRY_APP: {packet}\n\n") # get the telemetry data telemetry_packet = packet['decoded']['telemetry'] if telemetry_packet.get('deviceMetrics'): From 28e8e2705a9f1b110d5fe9300f1f019972eeabdf Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Tue, 24 Dec 2024 18:43:11 -0800 Subject: [PATCH 14/68] fix Keyerror --- modules/system.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/system.py b/modules/system.py index 075046e..e088c5a 100644 --- a/modules/system.py +++ b/modules/system.py @@ -916,38 +916,38 @@ def consumeMetadata(packet, rxNode=0): if packet_type == 'WAYPOINT_APP': if debugMetadata: print(f"DEBUG WAYPOINT_APP: {packet['decoded']['waypoint']}\n\n") # get the waypoint data - waypoint_data = packet['decoded']['waypoint'] + waypoint_data = packet['decoded'] keys = ['latitude', 'longitude',] # NEIGHBORINFO_APP if packet_type == 'NEIGHBORINFO_APP': if debugMetadata: print(f"DEBUG NEIGHBORINFO_APP: {packet}\n\n") # get the neighbor info data - neighbor_data = packet['decoded']['neighborInfo'] + neighbor_data = packet['decoded'] # TRACEROUTE_APP if packet_type == 'TRACEROUTE_APP': if debugMetadata: print(f"DEBUG TRACEROUTE_APP: {packet}\n\n") # get the traceroute data - traceroute_data = packet['decoded']['traceroute'] + traceroute_data = packet['decoded'] # DETECTION_SENSOR_APP if packet_type == 'DETECTION_SENSOR_APP': if debugMetadata: print(f"DEBUG DETECTION_SENSOR_APP: {packet}\n\n") # get the detection sensor data - detection_data = packet['decoded']['detectionSensor'] + detection_data = packet['decoded'] # PAXCOUNTER_APP if packet_type == 'PAXCOUNTER_APP': if debugMetadata: print(f"DEBUG PAXCOUNTER_APP: {packet}\n\n") # get the paxcounter data - paxcounter_data = packet['decoded']['paxcounter'] + paxcounter_data = packet['decoded'] # REMOTE_HARDWARE_APP if packet_type == 'REMOTE_HARDWARE_APP': if debugMetadata: print(f"DEBUG REMOTE_HARDWARE_APP: {packet}\n\n") # get the remote hardware data - remote_hardware_data = packet['decoded']['remoteHardware'] + remote_hardware_data = packet['decoded'] except KeyError as e: logger.critical(f"System: Error consuming metadata: {e} Device:{rxNode}") logger.debug(f"System: Error Packet = {packet}") From f7cdf446bf19f638852df0fdad4aaf48f0137072 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Tue, 24 Dec 2024 18:44:44 -0800 Subject: [PATCH 15/68] Update system.py --- modules/system.py | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/system.py b/modules/system.py index e088c5a..7ea7753 100644 --- a/modules/system.py +++ b/modules/system.py @@ -917,7 +917,6 @@ def consumeMetadata(packet, rxNode=0): if debugMetadata: print(f"DEBUG WAYPOINT_APP: {packet['decoded']['waypoint']}\n\n") # get the waypoint data waypoint_data = packet['decoded'] - keys = ['latitude', 'longitude',] # NEIGHBORINFO_APP if packet_type == 'NEIGHBORINFO_APP': From b95d94f06f444129f9be6b93c6f56eae03dfdc80 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Thu, 26 Dec 2024 09:29:30 -0800 Subject: [PATCH 16/68] alertChange --- modules/{locationdata_eu.py => globalalert.py} | 0 modules/system.py | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename modules/{locationdata_eu.py => globalalert.py} (100%) diff --git a/modules/locationdata_eu.py b/modules/globalalert.py similarity index 100% rename from modules/locationdata_eu.py rename to modules/globalalert.py diff --git a/modules/system.py b/modules/system.py index 7ea7753..cdd902c 100644 --- a/modules/system.py +++ b/modules/system.py @@ -76,7 +76,7 @@ if location_enabled: trap_list = trap_list + trap_list_location # items tide, whereami, wxc, wx help_message = help_message + ", whereami, wx, wxc, rlist" if enableGBalerts: - from modules.locationdata_eu import * # from the spudgunman/meshing-around repo + from modules.globalalert import * # from the spudgunman/meshing-around repo trap_list = trap_list + trap_list_location_eu #help_message = help_message + ", ukalert, ukwx, ukflood" From ed8636f5a5e5a0df0a45f9f48374f0818746066f Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Thu, 26 Dec 2024 16:28:52 -0800 Subject: [PATCH 17/68] Update config.template --- config.template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.template b/config.template index 0442a2f..e247481 100644 --- a/config.template +++ b/config.template @@ -237,7 +237,7 @@ splitDelay = 0.0 MESSAGE_CHUNK_SIZE = 160 # Request Acknowledgement of message OTA wantAck = False -# Max lilmit Buffer for radio testing +# Max limit buffer for radio testing. 233 is hard limit 2.5+ firmware maxBuffer = 220 From 8d2313cfb10821bc2748724dbe6f7bb60ddcedc0 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Fri, 27 Dec 2024 09:49:54 -0800 Subject: [PATCH 18/68] Update install.sh --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index dac96c5..6718fab 100755 --- a/install.sh +++ b/install.sh @@ -220,7 +220,7 @@ else replace="s|type = serial|type = tcp|g" sed -i "$replace" config.ini # replace "# hostname = 192.168.0.1" with "hostname = localhost" in config.ini - replace="s|# hostname = 192.168.0.1|hostname = localhost|g" + replace="s|# hostname = localhost|hostname = localhost|g" sed -i "$replace" config.ini printf "\nConfig file updated for embedded\n" From 170d1a6a454001fbe2ab58f4b6d5e411a8fcde60 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Fri, 27 Dec 2024 09:52:01 -0800 Subject: [PATCH 19/68] Update install.sh --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 6718fab..e4f9d16 100755 --- a/install.sh +++ b/install.sh @@ -12,7 +12,7 @@ printf "Installer works best in raspian/debian/ubuntu, if there is a problem, tr printf "\nChecking for dependencies...\n" # check if running on embedded -printf "\nAre You installing into an embedded system? (y/n)" +printf "\nAre You installing into an embedded system like a luckfox? (y/n)" read embedded if [ $embedded == "y" ]; then From c85d517b919e9d522220eb0fa82a566d20f680de Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Fri, 27 Dec 2024 10:03:13 -0800 Subject: [PATCH 20/68] Update install.sh --- install.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index e4f9d16..b56b46b 100755 --- a/install.sh +++ b/install.sh @@ -154,7 +154,6 @@ replace="s|Group=pi|Group=$whoami|g" sed -i $replace etc/pong_bot.service sed -i $replace etc/mesh_bot.service sed -i $replace etc/mesh_bot_reporting.service -sudo systemctl daemon-reload printf "\n service files updated\n" if [ $bot == "pong" ]; then @@ -164,6 +163,7 @@ if [ $bot == "pong" ]; then # install service for pong bot sudo cp etc/pong_bot.service /etc/systemd/system/ sudo systemctl enable pong_bot.service + sudo systemctl daemon-reload fi if [ $bot == "mesh" ]; then @@ -173,6 +173,7 @@ if [ $bot == "mesh" ]; then # install service for mesh bot sudo cp etc/mesh_bot.service /etc/systemd/system/ sudo systemctl enable mesh_bot.service + sudo systemctl daemon-reload fi # check if running on embedded From cef05e061c4c5f15fb86640217bb565a3e0c4f1a Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Fri, 27 Dec 2024 10:04:58 -0800 Subject: [PATCH 21/68] Update install.sh --- install.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/install.sh b/install.sh index b56b46b..11ebee8 100755 --- a/install.sh +++ b/install.sh @@ -157,9 +157,9 @@ sed -i $replace etc/mesh_bot_reporting.service printf "\n service files updated\n" if [ $bot == "pong" ]; then - echo "useradd -M meshbot" - echo "usermod -L meshbot" - echo "Added user meshbot with no home directory" + # echo "useradd -M meshbot" + # echo "usermod -L meshbot" + # echo "Added user meshbot with no home directory" # install service for pong bot sudo cp etc/pong_bot.service /etc/systemd/system/ sudo systemctl enable pong_bot.service @@ -167,9 +167,9 @@ if [ $bot == "pong" ]; then fi if [ $bot == "mesh" ]; then - echo "useradd -M meshbot" - echo "usermod -L meshbot" - echo "Added user meshbot with no home directory" + # echo "useradd -M meshbot" + # echo "usermod -L meshbot" + # echo "Added user meshbot with no home directory" # install service for mesh bot sudo cp etc/mesh_bot.service /etc/systemd/system/ sudo systemctl enable mesh_bot.service From c756b447ac4c089409afc4a19ef941c237ad5536 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Fri, 27 Dec 2024 10:28:01 -0800 Subject: [PATCH 22/68] Update install.sh --- install.sh | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/install.sh b/install.sh index 11ebee8..b0f00f1 100755 --- a/install.sh +++ b/install.sh @@ -145,7 +145,19 @@ sed -i $replace etc/pong_bot.service sed -i $replace etc/mesh_bot.service sed -i $replace etc/mesh_bot_reporting.service # set the correct user in the service file? -whoami=$(whoami) + +#ask if we should add a user for the bot +printf "\nDo you want to add a user (meshbot) no login for the bot? (y/n)" +read meshbotservice +if [ $meshbotservice == "y" ]; then + sudo useradd -M meshbot + sudo usermod -L meshbot + echo "Added user meshbot with no home directory" + whoami="meshbot" +else + whoami=$(whoami) +fi + replace="s|User=pi|User=$whoami|g" sed -i $replace etc/pong_bot.service sed -i $replace etc/mesh_bot.service @@ -157,9 +169,6 @@ sed -i $replace etc/mesh_bot_reporting.service printf "\n service files updated\n" if [ $bot == "pong" ]; then - # echo "useradd -M meshbot" - # echo "usermod -L meshbot" - # echo "Added user meshbot with no home directory" # install service for pong bot sudo cp etc/pong_bot.service /etc/systemd/system/ sudo systemctl enable pong_bot.service @@ -167,9 +176,6 @@ if [ $bot == "pong" ]; then fi if [ $bot == "mesh" ]; then - # echo "useradd -M meshbot" - # echo "usermod -L meshbot" - # echo "Added user meshbot with no home directory" # install service for mesh bot sudo cp etc/mesh_bot.service /etc/systemd/system/ sudo systemctl enable mesh_bot.service From eb8143f2983b2fe08384cbfcc10d97f20857183b Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Fri, 27 Dec 2024 13:36:15 -0800 Subject: [PATCH 23/68] Update install.sh --- install.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/install.sh b/install.sh index b0f00f1..ba5e1eb 100755 --- a/install.sh +++ b/install.sh @@ -173,6 +173,7 @@ if [ $bot == "pong" ]; then sudo cp etc/pong_bot.service /etc/systemd/system/ sudo systemctl enable pong_bot.service sudo systemctl daemon-reload + echo "to start pong bot service: systemctl start pong_bot" fi if [ $bot == "mesh" ]; then @@ -180,6 +181,7 @@ if [ $bot == "mesh" ]; then sudo cp etc/mesh_bot.service /etc/systemd/system/ sudo systemctl enable mesh_bot.service sudo systemctl daemon-reload + echo "to start mesh bot service: systemctl start mesh_bot" fi # check if running on embedded From a029334576988818d9492d1d66a2dcba4418a11c Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Fri, 27 Dec 2024 13:48:47 -0800 Subject: [PATCH 24/68] Update install.sh --- install.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/install.sh b/install.sh index ba5e1eb..27d7e76 100755 --- a/install.sh +++ b/install.sh @@ -154,6 +154,9 @@ if [ $meshbotservice == "y" ]; then sudo usermod -L meshbot echo "Added user meshbot with no home directory" whoami="meshbot" + sudo chown -R $whoami:$whoami $program_path/logs + sudo chown -R $whoami:$whoami $program_path/data + echo "Permissions set for meshbot on logs and data directories" else whoami=$(whoami) fi From 993fd760af87558dac2e195a9d6b595a984f476f Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Fri, 27 Dec 2024 13:55:41 -0800 Subject: [PATCH 25/68] Update install.sh --- install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 27d7e76..e9ee893 100755 --- a/install.sh +++ b/install.sh @@ -147,9 +147,9 @@ sed -i $replace etc/mesh_bot_reporting.service # set the correct user in the service file? #ask if we should add a user for the bot -printf "\nDo you want to add a user (meshbot) no login for the bot? (y/n)" +printf "\nDo you want to add a user (meshbot) no login, for the bot? (y/n)" read meshbotservice -if [ $meshbotservice == "y" ]; then +if [ $meshbotservice == "y" ] || [ $embedded == "y" ]; then sudo useradd -M meshbot sudo usermod -L meshbot echo "Added user meshbot with no home directory" From 3b73b665d6fd3553841d93db505f71d8b88eb4aa Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Fri, 27 Dec 2024 13:57:02 -0800 Subject: [PATCH 26/68] Update install.sh --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index e9ee893..af0a1b2 100755 --- a/install.sh +++ b/install.sh @@ -147,7 +147,7 @@ sed -i $replace etc/mesh_bot_reporting.service # set the correct user in the service file? #ask if we should add a user for the bot -printf "\nDo you want to add a user (meshbot) no login, for the bot? (y/n)" +printf "\nDo you want to add a user (meshbot) no login, for the bot? (y/n) (if embedded default is yes)" read meshbotservice if [ $meshbotservice == "y" ] || [ $embedded == "y" ]; then sudo useradd -M meshbot From cf16cc6606dced6ec841e8fe30712615474e0158 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Fri, 27 Dec 2024 13:58:31 -0800 Subject: [PATCH 27/68] Update install.sh --- install.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index af0a1b2..b364d46 100755 --- a/install.sh +++ b/install.sh @@ -11,9 +11,15 @@ printf "\nThis script will try and install the Meshing Around Bot and its depend printf "Installer works best in raspian/debian/ubuntu, if there is a problem, try running the installer again.\n" printf "\nChecking for dependencies...\n" -# check if running on embedded -printf "\nAre You installing into an embedded system like a luckfox? (y/n)" -read embedded +# if hostname = femtofox, then we are on embedded +if [ $(hostname) == "femtofox" ]; then + printf "\nDetected femtofox embedded system\n" + embedded="y" +else + # check if running on embedded + printf "\nAre You installing into an embedded system like a luckfox? (y/n)" + read embedded +fi if [ $embedded == "y" ]; then printf "\nDetected embedded skipping dependency installation\n" From 10918546d69140ac65f30e28bbe99718868addbf Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Fri, 27 Dec 2024 14:01:19 -0800 Subject: [PATCH 28/68] Update install.sh --- install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/install.sh b/install.sh index b364d46..91f35e4 100755 --- a/install.sh +++ b/install.sh @@ -143,6 +143,7 @@ fi printf "\n\n" echo "Which bot do you want to install as a service? Pong Mesh or None? (pong/mesh/n)" +echo "Pong bot is a simple bot for network testing, Mesh bot is a more complex bot more suited for meshing around" read bot # set the correct path in the service file From 23e0e4c6a06d8419ed142f384b53bf88cb55d921 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Fri, 27 Dec 2024 14:03:03 -0800 Subject: [PATCH 29/68] Update install.sh --- install.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 91f35e4..cdca5a3 100755 --- a/install.sh +++ b/install.sh @@ -154,8 +154,11 @@ sed -i $replace etc/mesh_bot_reporting.service # set the correct user in the service file? #ask if we should add a user for the bot -printf "\nDo you want to add a user (meshbot) no login, for the bot? (y/n) (if embedded default is yes)" -read meshbotservice +if [ $embedded != "y" ]; then + printf "\nDo you want to add a user (meshbot) no login, for the bot? (y/n) (if embedded default is yes)" + read meshbotservice +fi + if [ $meshbotservice == "y" ] || [ $embedded == "y" ]; then sudo useradd -M meshbot sudo usermod -L meshbot From a20e52050182b5a9e4c1369e1ddd4dddeece327b Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Fri, 27 Dec 2024 14:03:20 -0800 Subject: [PATCH 30/68] Update install.sh --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index cdca5a3..1c9a19b 100755 --- a/install.sh +++ b/install.sh @@ -155,7 +155,7 @@ sed -i $replace etc/mesh_bot_reporting.service #ask if we should add a user for the bot if [ $embedded != "y" ]; then - printf "\nDo you want to add a user (meshbot) no login, for the bot? (y/n) (if embedded default is yes)" + printf "\nDo you want to add a user (meshbot) no login, for the bot? (y/n)" read meshbotservice fi From 74cb135c6cc0225c35c12b602c65accc9b35b24b Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Fri, 27 Dec 2024 16:26:00 -0800 Subject: [PATCH 31/68] Update install.sh enhance embedded --- install.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index 1c9a19b..b0031c9 100755 --- a/install.sh +++ b/install.sh @@ -68,9 +68,15 @@ sudo usermod -a -G tty $USER sudo usermod -a -G bluetooth $USER # copy service files -cp etc/pong_bot.tmp etc/pong_bot.service -cp etc/mesh_bot.tmp etc/mesh_bot.service -cp etc/mesh_bot_reporting.tmp etc/mesh_bot_reporting.service +if ! cp etc/pong_bot.tmp etc/pong_bot.service; then + sudo cp etc/pong_bot.tmp etc/pong_bot.service +fi +if ! cp etc/mesh_bot.tmp etc/mesh_bot.service; then + sudo cp etc/mesh_bot.tmp etc/mesh_bot.service +fi +if ! cp etc/mesh_bot_reporting.tmp etc/mesh_bot_reporting.service; then + sudo cp etc/mesh_bot_reporting.tmp etc/mesh_bot_reporting.service +fi # generate config file, check if it exists if [ -f config.ini ]; then From 5f3c32dc0093652088dd3447d66b0e30db295d8e Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Fri, 27 Dec 2024 16:50:24 -0800 Subject: [PATCH 32/68] Update install.sh --- install.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/install.sh b/install.sh index b0031c9..e6a22a8 100755 --- a/install.sh +++ b/install.sh @@ -11,6 +11,12 @@ printf "\nThis script will try and install the Meshing Around Bot and its depend printf "Installer works best in raspian/debian/ubuntu, if there is a problem, try running the installer again.\n" printf "\nChecking for dependencies...\n" +# check write access to program path +if [ ! -w $program_path ]; then + printf "\nInstall path not writable, try running the installer with sudo\n" + exit 1 +fi + # if hostname = femtofox, then we are on embedded if [ $(hostname) == "femtofox" ]; then printf "\nDetected femtofox embedded system\n" @@ -68,15 +74,9 @@ sudo usermod -a -G tty $USER sudo usermod -a -G bluetooth $USER # copy service files -if ! cp etc/pong_bot.tmp etc/pong_bot.service; then - sudo cp etc/pong_bot.tmp etc/pong_bot.service -fi -if ! cp etc/mesh_bot.tmp etc/mesh_bot.service; then - sudo cp etc/mesh_bot.tmp etc/mesh_bot.service -fi -if ! cp etc/mesh_bot_reporting.tmp etc/mesh_bot_reporting.service; then - sudo cp etc/mesh_bot_reporting.tmp etc/mesh_bot_reporting.service -fi +cp etc/pong_bot.tmp etc/pong_bot.service +cp etc/mesh_bot.tmp etc/mesh_bot.service +cp etc/mesh_bot_reporting.tmp etc/mesh_bot_reporting.service # generate config file, check if it exists if [ -f config.ini ]; then From 0a4f1013707e5a52aa229885101b611e6d1e10e6 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Fri, 27 Dec 2024 17:22:58 -0800 Subject: [PATCH 33/68] Update install.sh --- install.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index e6a22a8..f9d2dd7 100755 --- a/install.sh +++ b/install.sh @@ -163,9 +163,11 @@ sed -i $replace etc/mesh_bot_reporting.service if [ $embedded != "y" ]; then printf "\nDo you want to add a user (meshbot) no login, for the bot? (y/n)" read meshbotservice +else + meshbotservice="n" fi -if [ $meshbotservice == "y" ] || [ $embedded == "y" ]; then +if [ "$meshbotservice" == "y" ] || [ "$embedded" == "y" ]; then sudo useradd -M meshbot sudo usermod -L meshbot echo "Added user meshbot with no home directory" From 9a11214208d1638eeb578b96ee6c669ed1713fe8 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Sat, 28 Dec 2024 09:28:08 -0800 Subject: [PATCH 34/68] fix alerting --- modules/system.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/system.py b/modules/system.py index cdd902c..2e9f657 100644 --- a/modules/system.py +++ b/modules/system.py @@ -702,7 +702,7 @@ def handleAlertBroadcast(deviceID=1): ukAlert = alertUk if emergencyAlertBrodcastEnabled: - if NO_ALERTS not in femaAlert: + if NO_ALERTS not in femaAlert and ERROR_FETCHING_DATA not in femaAlert: if isinstance(emergencyAlertBroadcastCh, list): for channel in emergencyAlertBroadcastCh: send_message(femaAlert, int(channel), 0, deviceID) @@ -1173,7 +1173,7 @@ async def watchdog(): # Alert Broadcast if wxAlertBroadcastEnabled or emergencyAlertBrodcastEnabled: # weather alerts - handleAlertBroadcast(1) + handleAlertBroadcast(2) # Telemetry data int2Data = displayNodeTelemetry(0, 2) From 1df3a7aaa23d5e7097f14ac07bd7fa38f90dac5e Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Wed, 1 Jan 2025 11:35:49 -0800 Subject: [PATCH 35/68] enhance --- mesh_bot.py | 2 +- pong_bot.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mesh_bot.py b/mesh_bot.py index 89a7b3d..0d6ccad 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -5,7 +5,7 @@ import asyncio import time # for sleep, get some when you can :) import random -from pubsub import pub # pip install pubsub +from pubsub import pub # pip install pubsub, use launch.sh for venv from modules.log import * from modules.system import * diff --git a/pong_bot.py b/pong_bot.py index 5e03fd3..d4639d5 100755 --- a/pong_bot.py +++ b/pong_bot.py @@ -4,7 +4,7 @@ import asyncio import time # for sleep, get some when you can :) -from pubsub import pub # pip install pubsub +from pubsub import pub # pip install pubsub, use launch.sh for venv from modules.log import * from modules.system import * From 3392d2d5a8c39285d88d5f99538c33e995d45948 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Wed, 1 Jan 2025 11:48:57 -0800 Subject: [PATCH 36/68] Update install.sh --- install.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index f9d2dd7..b43f99d 100755 --- a/install.sh +++ b/install.sh @@ -170,8 +170,13 @@ fi if [ "$meshbotservice" == "y" ] || [ "$embedded" == "y" ]; then sudo useradd -M meshbot sudo usermod -L meshbot - echo "Added user meshbot with no home directory" whoami="meshbot" + echo "Added user meshbot with no home directory" + sudo usermod -a -G dialout $whoami + sudo usermod -a -G tty $whoami + sudo usermod -a -G bluetooth $whoami + echo "Added meshbot to dialout, tty, and bluetooth groups" + sudo chown -R $whoami:$whoami $program_path/logs sudo chown -R $whoami:$whoami $program_path/data echo "Permissions set for meshbot on logs and data directories" From b94a5ebd8d8f73761bc726ac295dcdd63aafda59 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Thu, 2 Jan 2025 19:26:30 -0800 Subject: [PATCH 37/68] POSIX --- install.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/install.sh b/install.sh index b43f99d..4d3c226 100755 --- a/install.sh +++ b/install.sh @@ -27,13 +27,13 @@ else read embedded fi -if [ $embedded == "y" ]; then +if [ "$embedded" = "y" ] || [ "$embedded" = "yes" ]; then printf "\nDetected embedded skipping dependency installation\n" if [ $program_path != "/opt/meshing-around" ]; then printf "\nIt is suggested to project path to /opt/meshing-around\n" printf "Do you want to move the project to /opt/meshing-around? (y/n)" read move - if [ $move == "y" ]; then + if [ "$move" = "y" ] || [ "$move" = "yes" ]; then sudo mv $program_path /opt/meshing-around cd /opt/meshing-around printf "\nProject moved to /opt/meshing-around. re-run the installer\n" @@ -94,7 +94,7 @@ else printf "\nDo you want to install the bot in a python virtual environment? (y/n)" read venv - if [ $venv == "y" ]; then + if [ $venv = "y" ] || [ $venv = "yes" ]; then # set virtual environment if ! python3 -m venv --help &> /dev/null; then printf "Python3/venv error, please install python3-venv with your OS\n" @@ -139,7 +139,7 @@ else # install dependencies printf "Are you on Raspberry Pi(debian/ubuntu)?\nshould we add --break-system-packages to the pip install command? (y/n)" read rpi - if [ $rpi == "y" ]; then + if [ $rpi = "y" ] || [ $rpi = "yes" ]; then pip install -U -r requirements.txt --break-system-packages else pip install -U -r requirements.txt @@ -160,14 +160,14 @@ sed -i $replace etc/mesh_bot_reporting.service # set the correct user in the service file? #ask if we should add a user for the bot -if [ $embedded != "y" ]; then +if [ $embedded != "y" ] || [ $embedded != "yes" ]; then printf "\nDo you want to add a user (meshbot) no login, for the bot? (y/n)" read meshbotservice else meshbotservice="n" fi -if [ "$meshbotservice" == "y" ] || [ "$embedded" == "y" ]; then +if [ "$meshbotservice" == "y" ] || [ "$embedded" == "y" ] || [ "$embedded" == "yes" ] || [ "$meshbotservice" == "yes" ]; then sudo useradd -M meshbot sudo usermod -L meshbot whoami="meshbot" @@ -211,11 +211,11 @@ if [ $bot == "mesh" ]; then fi # check if running on embedded -if [ $embedded == "n" ]; then +if [ $embedded == "n" ] || [ $embedded == "no" ]; then # ask if emoji font should be installed for linux printf "\nDo you want to install the emoji font for debian/ubuntu linux? (y/n)" read emoji - if [ $emoji == "y" ]; then + if [ $emoji = "y" ] || [ $emoji = "yes" ]; then sudo apt-get install -y fonts-noto-color-emoji echo "Emoji font installed!, reboot to load the font" fi @@ -227,14 +227,14 @@ if [ $embedded == "n" ]; then # ask if the user wants to install the LLM Ollama components printf "\nDo you want to install the LLM Ollama components? (y/n)" read ollama - if [ $ollama == "y" ]; then + if [ $ollama = "y" ] || [ $ollama = "yes" ]; then curl -fsSL https://ollama.com/install.sh | sh # ask if want to install gemma2:2b printf "\n Ollama install done now we can install the Gemma2:2b components, multi GB download\n" echo "Do you want to install the Gemma2:2b components? (y/n)" read gemma - if [ $gemma == "y" ]; then + if [ $gemma = "y" ] || [ $gemma = "yes" ]; then ollama pull gemma2:2b fi fi From c11ebf1443e01ddb8dae4b968035774a0ea0faf1 Mon Sep 17 00:00:00 2001 From: joshbowyer <37744796+joshbowyer@users.noreply.github.com> Date: Thu, 2 Jan 2025 21:55:09 -0600 Subject: [PATCH 38/68] Update install.sh changed if statements to handle user input better --- install.sh | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/install.sh b/install.sh index 4d3c226..efd3d37 100755 --- a/install.sh +++ b/install.sh @@ -12,13 +12,13 @@ printf "Installer works best in raspian/debian/ubuntu, if there is a problem, tr printf "\nChecking for dependencies...\n" # check write access to program path -if [ ! -w $program_path ]; then +if [[ ! -w ${program_path} ]]; then printf "\nInstall path not writable, try running the installer with sudo\n" exit 1 fi # if hostname = femtofox, then we are on embedded -if [ $(hostname) == "femtofox" ]; then +if [[ $(hostname) == "femtofox" ]]; then printf "\nDetected femtofox embedded system\n" embedded="y" else @@ -27,13 +27,13 @@ else read embedded fi -if [ "$embedded" = "y" ] || [ "$embedded" = "yes" ]; then +if [[ $(echo "${embedded}" | grep -i "^y") ]]; then printf "\nDetected embedded skipping dependency installation\n" - if [ $program_path != "/opt/meshing-around" ]; then + if [[ ${program_path} != "/opt/meshing-around" ]]; then printf "\nIt is suggested to project path to /opt/meshing-around\n" printf "Do you want to move the project to /opt/meshing-around? (y/n)" read move - if [ "$move" = "y" ] || [ "$move" = "yes" ]; then + if [[ $(echo "${move}" | grep -i "^y") ]]; then sudo mv $program_path /opt/meshing-around cd /opt/meshing-around printf "\nProject moved to /opt/meshing-around. re-run the installer\n" @@ -79,7 +79,7 @@ cp etc/mesh_bot.tmp etc/mesh_bot.service cp etc/mesh_bot_reporting.tmp etc/mesh_bot_reporting.service # generate config file, check if it exists -if [ -f config.ini ]; then +if [[ -f config.ini ]]; then printf "\nConfig file already exists, moving to backup config.old\n" mv config.ini config.old fi @@ -88,13 +88,13 @@ cp config.template config.ini printf "\nConfig files generated!\n" # check if running on embedded -if [ $embedded == "y" ]; then +if [[ ${embedded} == "y" ]]; then printf "\nDetected embedded skipping venv\n" else printf "\nDo you want to install the bot in a python virtual environment? (y/n)" read venv - if [ $venv = "y" ] || [ $venv = "yes" ]; then + if [[ $(echo "${venv}" | grep -i "^y") ]]; then # set virtual environment if ! python3 -m venv --help &> /dev/null; then printf "Python3/venv error, please install python3-venv with your OS\n" @@ -103,7 +103,7 @@ else echo "The Following could be messy, or take some time on slower devices." echo "Creating virtual environment..." #check if python3 has venv module - if [ -f venv/bin/activate ]; then + if [[ -f venv/bin/activate ]]; then printf "\nFound virtual environment for python\n" python3 -m venv venv source venv/bin/activate @@ -115,7 +115,7 @@ else python3 -m venv venv # double check for python3-venv - if [ -f venv/bin/activate ]; then + if [[ -f venv/bin/activate ]]; then printf "\nFound virtual environment for python\n" source venv/bin/activate else @@ -139,7 +139,7 @@ else # install dependencies printf "Are you on Raspberry Pi(debian/ubuntu)?\nshould we add --break-system-packages to the pip install command? (y/n)" read rpi - if [ $rpi = "y" ] || [ $rpi = "yes" ]; then + if [[ $(echo "${rpi}" | grep -i "^y") ]]; then pip install -U -r requirements.txt --break-system-packages else pip install -U -r requirements.txt @@ -160,14 +160,14 @@ sed -i $replace etc/mesh_bot_reporting.service # set the correct user in the service file? #ask if we should add a user for the bot -if [ $embedded != "y" ] || [ $embedded != "yes" ]; then +if [[ $(echo "${embedded}" | grep -i "^y") ]]; then printf "\nDo you want to add a user (meshbot) no login, for the bot? (y/n)" read meshbotservice else meshbotservice="n" fi -if [ "$meshbotservice" == "y" ] || [ "$embedded" == "y" ] || [ "$embedded" == "yes" ] || [ "$meshbotservice" == "yes" ]; then +if [[ $(echo "${meshbotservice}" | grep -i "^y") ]] || [[ $(echo "${embedded}" | grep -i "^y") ]]; then sudo useradd -M meshbot sudo usermod -L meshbot whoami="meshbot" @@ -194,7 +194,7 @@ sed -i $replace etc/mesh_bot.service sed -i $replace etc/mesh_bot_reporting.service printf "\n service files updated\n" -if [ $bot == "pong" ]; then +if [[ $(echo "${bot}" | grep -i "^p") ]]; then # install service for pong bot sudo cp etc/pong_bot.service /etc/systemd/system/ sudo systemctl enable pong_bot.service @@ -202,7 +202,7 @@ if [ $bot == "pong" ]; then echo "to start pong bot service: systemctl start pong_bot" fi -if [ $bot == "mesh" ]; then +if [[ $(echo "${bot}" | grep -i "^m") ]]; then # install service for mesh bot sudo cp etc/mesh_bot.service /etc/systemd/system/ sudo systemctl enable mesh_bot.service @@ -211,11 +211,11 @@ if [ $bot == "mesh" ]; then fi # check if running on embedded -if [ $embedded == "n" ] || [ $embedded == "no" ]; then +if [[ $(echo "${embedded}" | grep -i "^n") ]]; then # ask if emoji font should be installed for linux printf "\nDo you want to install the emoji font for debian/ubuntu linux? (y/n)" read emoji - if [ $emoji = "y" ] || [ $emoji = "yes" ]; then + if [[ $(echo "${emoji}" | grep -i "^y") ]]; then sudo apt-get install -y fonts-noto-color-emoji echo "Emoji font installed!, reboot to load the font" fi @@ -227,26 +227,26 @@ if [ $embedded == "n" ] || [ $embedded == "no" ]; then # ask if the user wants to install the LLM Ollama components printf "\nDo you want to install the LLM Ollama components? (y/n)" read ollama - if [ $ollama = "y" ] || [ $ollama = "yes" ]; then + if [[ $(echo "${ollama}" | grep -i "^y") ]]; then curl -fsSL https://ollama.com/install.sh | sh # ask if want to install gemma2:2b printf "\n Ollama install done now we can install the Gemma2:2b components, multi GB download\n" echo "Do you want to install the Gemma2:2b components? (y/n)" read gemma - if [ $gemma = "y" ] || [ $gemma = "yes" ]; then + if [[ $(echo "${gemma}" | grep -i "^y") ]]; then ollama pull gemma2:2b fi fi - if [ $venv == "y" ]; then + if [[ $(echo "${venv}" | grep -i "^y") ]]; then printf "\nFor running in virtual, launch bot with './launch.sh mesh' in path $program_path\n" fi printf "\nGood time to reboot? (y/n)" read reboot - if [ $reboot == "y" ]; then + if [[ $(echo "${reboot}" | grep -i "^y") ]]; then sudo reboot fi else From f12198b14038f37149e1722882f4247bdf510d5b Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Thu, 2 Jan 2025 20:23:04 -0800 Subject: [PATCH 39/68] enhance --- install.sh | 59 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 25 deletions(-) diff --git a/install.sh b/install.sh index efd3d37..2c84599 100755 --- a/install.sh +++ b/install.sh @@ -11,6 +11,19 @@ printf "\nThis script will try and install the Meshing Around Bot and its depend printf "Installer works best in raspian/debian/ubuntu, if there is a problem, try running the installer again.\n" printf "\nChecking for dependencies...\n" +# check if we are in /opt/meshing-around +if [ $program_path != "/opt/meshing-around" ]; then + printf "\nIt is suggested to project path to /opt/meshing-around\n" + printf "Do you want to move the project to /opt/meshing-around? (y/n)" + read move + if [[ $(echo "$move" | grep -iq "^y") ]]; then + sudo mv $program_path /opt/meshing-around + cd /opt/meshing-around + printf "\nProject moved to /opt/meshing-around. re-run the installer\n" + exit 0 + fi +fi + # check write access to program path if [[ ! -w ${program_path} ]]; then printf "\nInstall path not writable, try running the installer with sudo\n" @@ -29,17 +42,6 @@ fi if [[ $(echo "${embedded}" | grep -i "^y") ]]; then printf "\nDetected embedded skipping dependency installation\n" - if [[ ${program_path} != "/opt/meshing-around" ]]; then - printf "\nIt is suggested to project path to /opt/meshing-around\n" - printf "Do you want to move the project to /opt/meshing-around? (y/n)" - read move - if [[ $(echo "${move}" | grep -i "^y") ]]; then - sudo mv $program_path /opt/meshing-around - cd /opt/meshing-around - printf "\nProject moved to /opt/meshing-around. re-run the installer\n" - exit 0 - fi - fi else # Check and install dependencies if ! command -v python3 &> /dev/null @@ -88,10 +90,10 @@ cp config.template config.ini printf "\nConfig files generated!\n" # check if running on embedded -if [[ ${embedded} == "y" ]]; then +if [[ $(echo "${embedded}" | grep -iq "^y") ]]; then printf "\nDetected embedded skipping venv\n" else - printf "\nDo you want to install the bot in a python virtual environment? (y/n)" + printf "\nRecomended install is in a python virtual environment, do you want to use venv? (y/n)" read venv if [[ $(echo "${venv}" | grep -i "^y") ]]; then @@ -131,12 +133,12 @@ else replace="s|python3 pong_bot.py|/usr/bin/bash launch.sh pong|g" sed -i "$replace" etc/pong_bot.service - # install dependencies + # install dependencies to venv pip install -U -r requirements.txt fi else printf "\nSkipping virtual environment...\n" - # install dependencies + # install dependencies to system printf "Are you on Raspberry Pi(debian/ubuntu)?\nshould we add --break-system-packages to the pip install command? (y/n)" read rpi if [[ $(echo "${rpi}" | grep -i "^y") ]]; then @@ -161,7 +163,7 @@ sed -i $replace etc/mesh_bot_reporting.service #ask if we should add a user for the bot if [[ $(echo "${embedded}" | grep -i "^y") ]]; then - printf "\nDo you want to add a user (meshbot) no login, for the bot? (y/n)" + printf "\nDo you want to add a local user (meshbot) no login, for the bot? (y/n)" read meshbotservice else meshbotservice="n" @@ -183,7 +185,7 @@ if [[ $(echo "${meshbotservice}" | grep -i "^y") ]] || [[ $(echo "${embedded}" | else whoami=$(whoami) fi - +# set the correct user in the service file replace="s|User=pi|User=$whoami|g" sed -i $replace etc/pong_bot.service sed -i $replace etc/mesh_bot.service @@ -210,7 +212,7 @@ if [[ $(echo "${bot}" | grep -i "^m") ]]; then echo "to start mesh bot service: systemctl start mesh_bot" fi -# check if running on embedded +# check if running on embedded for final steps if [[ $(echo "${embedded}" | grep -i "^n") ]]; then # ask if emoji font should be installed for linux printf "\nDo you want to install the emoji font for debian/ubuntu linux? (y/n)" @@ -220,10 +222,10 @@ if [[ $(echo "${embedded}" | grep -i "^n") ]]; then echo "Emoji font installed!, reboot to load the font" fi - printf "\nOptionally if you want to install the multi gig LLM Ollama compnents we will execute the following commands\n" printf "\ncurl -fsSL https://ollama.com/install.sh | sh\n" - + printf "ollama pull gemma2:2b\n" + printf "Total download is multi GB, recomend pi5/8GB or better for this\n" # ask if the user wants to install the LLM Ollama components printf "\nDo you want to install the LLM Ollama components? (y/n)" read ollama @@ -231,7 +233,7 @@ if [[ $(echo "${embedded}" | grep -i "^n") ]]; then curl -fsSL https://ollama.com/install.sh | sh # ask if want to install gemma2:2b - printf "\n Ollama install done now we can install the Gemma2:2b components, multi GB download\n" + printf "\n Ollama install done now we can install the Gemma2:2b components\n" echo "Do you want to install the Gemma2:2b components? (y/n)" read gemma if [[ $(echo "${gemma}" | grep -i "^y") ]]; then @@ -239,9 +241,8 @@ if [[ $(echo "${embedded}" | grep -i "^n") ]]; then fi fi - if [[ $(echo "${venv}" | grep -i "^y") ]]; then - printf "\nFor running in virtual, launch bot with './launch.sh mesh' in path $program_path\n" + printf "\nFor running on venv, virtual launch bot with './launch.sh mesh' in path $program_path\n" fi printf "\nGood time to reboot? (y/n)" @@ -260,8 +261,16 @@ else printf "\nConfig file updated for embedded\n" # Set up the meshing around service - #sudo cp /opt/meshing-around/meshing-around.service /etc/systemd/system/meshing-around.service - #sudo systemctl enable meshing-around.service + printf "To install the meshing around service and keep notes, copy and paste the following commands:\n\n" + printf "sudo cp /opt/meshing-around/meshing-around.service /etc/systemd/system/meshing-around.service\n" + printf "sudo systemctl daemon-reload\n" + printf "sudo systemctl enable meshing-around.service\n" + printf "sudo systemctl start meshing-around.service\n" + printf "sudo systemctl status meshing-around.service\n\n" + printf "To see logs and stop the service:\n" + printf "sudo journalctl -u meshing-around.service\n" + printf "sudo systemctl stop meshing-around.service\n" + printf "sudo systemctl disable meshing-around.service\n" fi printf "\nInstallation complete!\n" From 7fa59285377dc8f2110cc5b754b917dd7c01a338 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Thu, 2 Jan 2025 20:27:50 -0800 Subject: [PATCH 40/68] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 20b629b..4c9bdbb 100644 --- a/README.md +++ b/README.md @@ -440,6 +440,8 @@ I used ideas and snippets from other responder bots and want to call them out! - **[https://github.com/A-c0rN](A-c0rN)**: Assistance with iPAWS and EAS - **Mike O'Connell/skrrt**: For [eas_alert_parser](etc/eas_alert_parser.py) enhanced by **sheer.cold** - **PiDiBi**: For looking at test functions and other suggestions like wxc, CPU use, and alerting ideas. +- **WH6GXZ nurse dude**: For bashing on installer +- **Josh**: For more bashing on installer! - **Cisien, bitflip, **Woof**, **propstg**, **Josh** and Hailo1999**: For testing and feature ideas on Discord and GitHub. - **Meshtastic Discord Community**: For tossing out ideas and testing code. From b4168214b6599d037009bc2037effd1c4136a074 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Thu, 2 Jan 2025 21:02:14 -0800 Subject: [PATCH 41/68] #hints --- mesh_bot.py | 2 +- modules/system.py | 2 +- pong_bot.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mesh_bot.py b/mesh_bot.py index 0d6ccad..39d0dc2 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -5,7 +5,7 @@ import asyncio import time # for sleep, get some when you can :) import random -from pubsub import pub # pip install pubsub, use launch.sh for venv +from pubsub import pub # pip install pubsub or use launch.sh for venv from modules.log import * from modules.system import * diff --git a/modules/system.py b/modules/system.py index 2e9f657..7caea4b 100644 --- a/modules/system.py +++ b/modules/system.py @@ -1,7 +1,7 @@ # helper functions and init for system related tasks # K7MHI Kelly Keeton 2024 -import meshtastic.serial_interface #pip install meshtastic +import meshtastic.serial_interface #pip install meshtastic or use launch.sh for venv import meshtastic.tcp_interface import meshtastic.ble_interface import time diff --git a/pong_bot.py b/pong_bot.py index d4639d5..24c2c68 100755 --- a/pong_bot.py +++ b/pong_bot.py @@ -4,7 +4,7 @@ import asyncio import time # for sleep, get some when you can :) -from pubsub import pub # pip install pubsub, use launch.sh for venv +from pubsub import pub # pip install pubsub or use launch.sh for venv from modules.log import * from modules.system import * From b0e57e8aca66f7ed4b4c1373e850f291f540a99d Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Thu, 2 Jan 2025 21:57:53 -0800 Subject: [PATCH 42/68] cleanup Embedded --- config.template | 9 +++++---- install.sh | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/config.template b/config.template index e247481..d69aa4d 100644 --- a/config.template +++ b/config.template @@ -8,8 +8,7 @@ type = serial port = /dev/ttyACM0 # port = /dev/ttyUSB0 -# port = COM1 -# hostname = localhost +# hostname = meshtastic.local # mac = 00:11:22:33:44:55 # Additional interface for dual radio support @@ -17,9 +16,9 @@ port = /dev/ttyACM0 enabled = False type = serial port = /dev/ttyUSB0 -#port = /dev/ttyACM1 +# port = /dev/ttyACM1 # port = COM1 -# hostname = meshtastic.local +# hostname = localhost # mac = 00:11:22:33:44:55 [general] @@ -74,6 +73,8 @@ urlTimeout = 10 LogMessagesToFile = False # Logging of system messages to file SyslogToFile = True +# logging level for the bot (DEBUG, INFO, WARNING, ERROR, CRITICAL) +sysloglevel = DEBUG # Number of log files to keep in days, 0 to keep all log_backup_count = 32 diff --git a/install.sh b/install.sh index 2c84599..500c68e 100755 --- a/install.sh +++ b/install.sh @@ -255,8 +255,8 @@ else # replace "type = serial" with "type = tcp" in config.ini replace="s|type = serial|type = tcp|g" sed -i "$replace" config.ini - # replace "# hostname = 192.168.0.1" with "hostname = localhost" in config.ini - replace="s|# hostname = localhost|hostname = localhost|g" + # replace "# hostname = meshtastic.local" with "hostname = localhost" in config.ini + replace="s|# hostname = meshtastic.local|hostname = localhost|g" sed -i "$replace" config.ini printf "\nConfig file updated for embedded\n" From e3c5eb6addf38fc3da487260fbe04bddf4f888e8 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Thu, 2 Jan 2025 21:58:15 -0800 Subject: [PATCH 43/68] logLevel in Config sysloglevel = DEBUG in config.ini --- logs/README.md | 2 ++ modules/log.py | 11 ++++++++--- modules/settings.py | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/logs/README.md b/logs/README.md index e18eccc..1520215 100644 --- a/logs/README.md +++ b/logs/README.md @@ -14,6 +14,8 @@ Logging messages to disk or 'Syslog' to disk uses the python native logging func LogMessagesToFile = False # Logging of system messages to file, needed for reporting engine SyslogToFile = True +# logging level for the bot (DEBUG, INFO, WARNING, ERROR, CRITICAL) +sysloglevel = DEBUG # Number of log files to keep in days, 0 to keep all log_backup_count = 32 ``` diff --git a/modules/log.py b/modules/log.py index f8174ec..9191907 100644 --- a/modules/log.py +++ b/modules/log.py @@ -3,6 +3,11 @@ from logging.handlers import TimedRotatingFileHandler import re from datetime import datetime from modules.settings import * +# if LOGGING_LEVEL is not set in settings.py, default to DEBUG +if not LOGGING_LEVEL: + LOGGING_LEVEL = "DEBUG" + +LOGGING_LEVEL = getattr(logging, LOGGING_LEVEL) class CustomFormatter(logging.Formatter): grey = '\x1b[38;21m' @@ -41,7 +46,7 @@ class plainFormatter(logging.Formatter): # Create logger logger = logging.getLogger("MeshBot System Logger") -logger.setLevel(logging.DEBUG) +logger.setLevel(LOGGING_LEVEL) logger.propagate = False msgLogger = logging.getLogger("MeshBot Messages Logger") @@ -56,7 +61,7 @@ today = datetime.now() # Create stdout handler for logging to the console stdout_handler = logging.StreamHandler() # Set level for stdout handler (logs DEBUG level and above) -stdout_handler.setLevel(logging.DEBUG) +stdout_handler.setLevel(LOGGING_LEVEL) # Set format for stdout handler stdout_handler.setFormatter(CustomFormatter(logFormat)) # Add handlers to the logger @@ -65,7 +70,7 @@ logger.addHandler(stdout_handler) if syslog_to_file: # Create file handler for logging to a file file_handler_sys = TimedRotatingFileHandler('logs/meshbot.log', when='midnight', backupCount=log_backup_count) - file_handler_sys.setLevel(logging.DEBUG) # DEBUG used by default for system logs to disk + file_handler_sys.setLevel(LOGGING_LEVEL) # DEBUG used by default for system logs to disk file_handler_sys.setFormatter(plainFormatter(logFormat)) logger.addHandler(file_handler_sys) diff --git a/modules/settings.py b/modules/settings.py index 034ae8c..73af4a7 100644 --- a/modules/settings.py +++ b/modules/settings.py @@ -117,6 +117,7 @@ try: log_messages_to_file = config['general'].getboolean('LogMessagesToFile', False) # default off log_backup_count = config['general'].getint('LogBackupCount', 32) # default 32 days syslog_to_file = config['general'].getboolean('SyslogToFile', True) # default on + LOGGING_LEVEL = config['general'].get('sysloglevel', 'DEBUG') # default DEBUG urlTimeoutSeconds = config['general'].getint('urlTimeout', 10) # default 10 seconds store_forward_enabled = config['general'].getboolean('StoreForward', True) storeFlimit = config['general'].getint('StoreLimit', 3) # default 3 messages for S&F @@ -136,7 +137,6 @@ try: llm_enabled = config['general'].getboolean('ollama', False) # https://ollama.com llmModel = config['general'].get('ollamaModel', 'gemma2:2b') # default gemma2:2b ollamaHostName = config['general'].get('ollamaHostName', 'http://localhost:11434') # default localhost - # emergency response emergency_responder_enabled = config['emergencyHandler'].getboolean('enabled', False) emergency_responder_alert_channel = config['emergencyHandler'].getint('alert_channel', 2) # default 2 From d7af337a63c725e06cb1e644e8dc1453e9e404ac Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Thu, 2 Jan 2025 22:06:00 -0800 Subject: [PATCH 44/68] enhance --- mesh_bot.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mesh_bot.py b/mesh_bot.py index 39d0dc2..d2ff88a 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -2,10 +2,15 @@ # Meshtastic Autoresponder MESH Bot # K7MHI Kelly Keeton 2024 +try: + from pubsub import pub +except ImportError: + print(f"Important dependencies are not met, try install.sh\n\n Did you mean to './launch.sh mesh' using a virtual environment.") + exit(1) + import asyncio import time # for sleep, get some when you can :) import random -from pubsub import pub # pip install pubsub or use launch.sh for venv from modules.log import * from modules.system import * From db9b89d0acdca2e1b8bc66833e9d59298cfa9c6c Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Thu, 2 Jan 2025 22:08:59 -0800 Subject: [PATCH 45/68] Update pong_bot.py --- pong_bot.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pong_bot.py b/pong_bot.py index 24c2c68..b0c4fe8 100755 --- a/pong_bot.py +++ b/pong_bot.py @@ -2,9 +2,15 @@ # Meshtastic Autoresponder PONG Bot # K7MHI Kelly Keeton 2024 +try: + from pubsub import pub +except ImportError: + print(f"Important dependencies are not met, try install.sh\n\n Did you mean to './launch.sh pong' using a virtual environment.") + exit(1) + import asyncio import time # for sleep, get some when you can :) -from pubsub import pub # pip install pubsub or use launch.sh for venv +import random from modules.log import * from modules.system import * From 7eb629676b4f6edaa3cdd7b1af9f6a22d23db41f Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Thu, 2 Jan 2025 22:11:49 -0800 Subject: [PATCH 46/68] Update install.sh --- install.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/install.sh b/install.sh index 500c68e..c34a4e9 100755 --- a/install.sh +++ b/install.sh @@ -262,15 +262,15 @@ else # Set up the meshing around service printf "To install the meshing around service and keep notes, copy and paste the following commands:\n\n" - printf "sudo cp /opt/meshing-around/meshing-around.service /etc/systemd/system/meshing-around.service\n" + printf "sudo cp /opt/meshing-around/mesh_bot.service /etc/systemd/system/mesh_bot.service\n" printf "sudo systemctl daemon-reload\n" - printf "sudo systemctl enable meshing-around.service\n" - printf "sudo systemctl start meshing-around.service\n" - printf "sudo systemctl status meshing-around.service\n\n" + printf "sudo systemctl enable mesh_bot.service\n" + printf "sudo systemctl start mesh_bot.service\n" + printf "sudo systemctl status mesh_bot.service\n\n" printf "To see logs and stop the service:\n" - printf "sudo journalctl -u meshing-around.service\n" - printf "sudo systemctl stop meshing-around.service\n" - printf "sudo systemctl disable meshing-around.service\n" + printf "sudo journalctl -u mesh_bot.service\n" + printf "sudo systemctl stop mesh_bot.service\n" + printf "sudo systemctl disable mesh_bot.service\n" fi printf "\nInstallation complete!\n" From 5373b61f8375e79a48a4d38c16253586e28fff6e Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Thu, 2 Jan 2025 22:14:13 -0800 Subject: [PATCH 47/68] enhance --- install.sh | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/install.sh b/install.sh index c34a4e9..de44614 100755 --- a/install.sh +++ b/install.sh @@ -202,6 +202,7 @@ if [[ $(echo "${bot}" | grep -i "^p") ]]; then sudo systemctl enable pong_bot.service sudo systemctl daemon-reload echo "to start pong bot service: systemctl start pong_bot" + service="pong_bot" fi if [[ $(echo "${bot}" | grep -i "^m") ]]; then @@ -210,6 +211,7 @@ if [[ $(echo "${bot}" | grep -i "^m") ]]; then sudo systemctl enable mesh_bot.service sudo systemctl daemon-reload echo "to start mesh bot service: systemctl start mesh_bot" + service="mesh_bot" fi # check if running on embedded for final steps @@ -261,16 +263,16 @@ else printf "\nConfig file updated for embedded\n" # Set up the meshing around service - printf "To install the meshing around service and keep notes, copy and paste the following commands:\n\n" - printf "sudo cp /opt/meshing-around/mesh_bot.service /etc/systemd/system/mesh_bot.service\n" + printf "To install the %s service and keep notes, copy and paste the following commands:\n\n" "$service" + printf "sudo cp /opt/meshing-around/%s.service /etc/systemd/system/%s.service\n" "$service" "$service" printf "sudo systemctl daemon-reload\n" - printf "sudo systemctl enable mesh_bot.service\n" - printf "sudo systemctl start mesh_bot.service\n" - printf "sudo systemctl status mesh_bot.service\n\n" + printf "sudo systemctl enable %s.service\n" "$service" + printf "sudo systemctl start %s.service\n" "$service" + printf "sudo systemctl status %s.service\n\n" "$service" printf "To see logs and stop the service:\n" - printf "sudo journalctl -u mesh_bot.service\n" - printf "sudo systemctl stop mesh_bot.service\n" - printf "sudo systemctl disable mesh_bot.service\n" + printf "sudo journalctl -u %s.service\n" "$service" + printf "sudo systemctl stop %s.service\n" "$service" + printf "sudo systemctl disable %s.service\n" "$service" fi printf "\nInstallation complete!\n" From 30131bc6d54ede6706497a696d524688f2e2db97 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Thu, 2 Jan 2025 22:24:42 -0800 Subject: [PATCH 48/68] Update install.sh --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index de44614..e526ba8 100755 --- a/install.sh +++ b/install.sh @@ -16,7 +16,7 @@ if [ $program_path != "/opt/meshing-around" ]; then printf "\nIt is suggested to project path to /opt/meshing-around\n" printf "Do you want to move the project to /opt/meshing-around? (y/n)" read move - if [[ $(echo "$move" | grep -iq "^y") ]]; then + if [[ $(echo "$move" | grep -i "^y") ]]; then sudo mv $program_path /opt/meshing-around cd /opt/meshing-around printf "\nProject moved to /opt/meshing-around. re-run the installer\n" From 15d7f75507651f58f5961941fdaecbd97c5b4128 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Fri, 3 Jan 2025 22:29:40 -0800 Subject: [PATCH 49/68] femtofox butfix @noon92 this fixes the problem you saw --- install.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index e526ba8..59a8200 100755 --- a/install.sh +++ b/install.sh @@ -8,7 +8,8 @@ printf "\n########################" printf "\nMeshing Around Installer\n" printf "########################\n" printf "\nThis script will try and install the Meshing Around Bot and its dependencies." -printf "Installer works best in raspian/debian/ubuntu, if there is a problem, try running the installer again.\n" +printf "Installer works best in raspian/debian/ubuntu or foxbuntu embedded systems.\n" +printf "If there is a problem, try running the installer again.\n" printf "\nChecking for dependencies...\n" # check if we are in /opt/meshing-around @@ -90,7 +91,7 @@ cp config.template config.ini printf "\nConfig files generated!\n" # check if running on embedded -if [[ $(echo "${embedded}" | grep -iq "^y") ]]; then +if [[ $(echo "${embedded}" | grep -i "^y") ]]; then printf "\nDetected embedded skipping venv\n" else printf "\nRecomended install is in a python virtual environment, do you want to use venv? (y/n)" From 2c4cfa9e81fdd6d15ac3ca2c1b3cfe58f98f9142 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Fri, 3 Jan 2025 22:40:15 -0800 Subject: [PATCH 50/68] Update install.sh --- install.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/install.sh b/install.sh index 59a8200..b3c5b13 100755 --- a/install.sh +++ b/install.sh @@ -163,11 +163,9 @@ sed -i $replace etc/mesh_bot_reporting.service # set the correct user in the service file? #ask if we should add a user for the bot -if [[ $(echo "${embedded}" | grep -i "^y") ]]; then +if [[ $(echo "${embedded}" | grep -i "^n") ]]; then printf "\nDo you want to add a local user (meshbot) no login, for the bot? (y/n)" read meshbotservice -else - meshbotservice="n" fi if [[ $(echo "${meshbotservice}" | grep -i "^y") ]] || [[ $(echo "${embedded}" | grep -i "^y") ]]; then From 475d475e188fb2da703adce33f53b49c129f4e68 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Fri, 3 Jan 2025 22:43:56 -0800 Subject: [PATCH 51/68] Update install.sh --- install.sh | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/install.sh b/install.sh index b3c5b13..29394d5 100755 --- a/install.sh +++ b/install.sh @@ -242,6 +242,20 @@ if [[ $(echo "${embedded}" | grep -i "^n") ]]; then fi fi + if [[ $(echo "${meshbotservice}" | grep -i "^y") ]] + # document the service install + printf "To install the %s service and keep notes, copy and paste the following commands:\n\n" "$service" + printf "sudo cp /opt/meshing-around/%s.service /etc/systemd/system/%s.service\n" "$service" "$service" + printf "sudo systemctl daemon-reload\n" + printf "sudo systemctl enable %s.service\n" "$service" + printf "sudo systemctl start %s.service\n" "$service" + printf "sudo systemctl status %s.service\n\n" "$service" + printf "To see logs and stop the service:\n" + printf "sudo journalctl -u %s.service\n" "$service" + printf "sudo systemctl stop %s.service\n" "$service" + printf "sudo systemctl disable %s.service\n" "$service" + fi + if [[ $(echo "${venv}" | grep -i "^y") ]]; then printf "\nFor running on venv, virtual launch bot with './launch.sh mesh' in path $program_path\n" fi @@ -262,11 +276,11 @@ else printf "\nConfig file updated for embedded\n" # Set up the meshing around service - printf "To install the %s service and keep notes, copy and paste the following commands:\n\n" "$service" - printf "sudo cp /opt/meshing-around/%s.service /etc/systemd/system/%s.service\n" "$service" "$service" - printf "sudo systemctl daemon-reload\n" - printf "sudo systemctl enable %s.service\n" "$service" - printf "sudo systemctl start %s.service\n" "$service" + sudo cp /opt/meshing-around/$service.service /etc/systemd/system/$service.service + sudo systemctl daemon-reload + sudo systemctl enable $service.service + sudo systemctl start $service.service + printf "sudo systemctl status %s.service\n\n" "$service" printf "To see logs and stop the service:\n" printf "sudo journalctl -u %s.service\n" "$service" From 9e5285a845705eb452c52866be7c3c8e05e89b4d Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Fri, 3 Jan 2025 22:48:41 -0800 Subject: [PATCH 52/68] Update install.sh --- install.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/install.sh b/install.sh index 29394d5..017b48a 100755 --- a/install.sh +++ b/install.sh @@ -286,9 +286,11 @@ else printf "sudo journalctl -u %s.service\n" "$service" printf "sudo systemctl stop %s.service\n" "$service" printf "sudo systemctl disable %s.service\n" "$service" + read -p "Press enter to complete the installation" fi printf "\nInstallation complete!\n" + exit 0 # after install shenannigans # add 'bee = True' to config.ini General section. You will likley want to clean the txt up a bit From b04368f85209f3faed6d5e7ab1a69a4382157109 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Fri, 3 Jan 2025 23:11:03 -0800 Subject: [PATCH 53/68] location aware @Ruledo thanks for the idea for this! --- install.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/install.sh b/install.sh index 017b48a..8f401f3 100755 --- a/install.sh +++ b/install.sh @@ -90,6 +90,14 @@ fi cp config.template config.ini printf "\nConfig files generated!\n" +# update lat,long in config.ini +latlong=$(curl --silent --max-time 20 https://ipinfo.io/loc || echo "48.50,-123.0") +IFS=',' read -r lat lon <<< "$latlong" +echo "lat: $lat, lon: $lon" +sed -i "s|lat = 48.50|lat = $lat|g" config.ini +sed -i "s|lon = -123.0|lon = $lon|g" config.ini +echo "lat,long updated in config.ini to $latlong" + # check if running on embedded if [[ $(echo "${embedded}" | grep -i "^y") ]]; then printf "\nDetected embedded skipping venv\n" From 70659c9c148cbcc431c4976cc4620647d84e79f3 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Fri, 3 Jan 2025 23:31:08 -0800 Subject: [PATCH 54/68] Update install.sh --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 8f401f3..ec99422 100755 --- a/install.sh +++ b/install.sh @@ -7,7 +7,7 @@ program_path=$(pwd) printf "\n########################" printf "\nMeshing Around Installer\n" printf "########################\n" -printf "\nThis script will try and install the Meshing Around Bot and its dependencies." +printf "\nThis script will try and install the Meshing Around Bot and its dependencies.\n" printf "Installer works best in raspian/debian/ubuntu or foxbuntu embedded systems.\n" printf "If there is a problem, try running the installer again.\n" printf "\nChecking for dependencies...\n" From cf16fc3db7bb988e2359752ca620685fe768e70f Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Fri, 3 Jan 2025 23:39:59 -0800 Subject: [PATCH 55/68] Update install.sh --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index ec99422..ab3a978 100755 --- a/install.sh +++ b/install.sh @@ -250,7 +250,7 @@ if [[ $(echo "${embedded}" | grep -i "^n") ]]; then fi fi - if [[ $(echo "${meshbotservice}" | grep -i "^y") ]] + if [[ $(echo "${meshbotservice}" | grep -i "^y") ]]; then # document the service install printf "To install the %s service and keep notes, copy and paste the following commands:\n\n" "$service" printf "sudo cp /opt/meshing-around/%s.service /etc/systemd/system/%s.service\n" "$service" "$service" From 5d5595ef8b81dada8a6813f612f9fd1ff3352876 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Fri, 3 Jan 2025 23:42:00 -0800 Subject: [PATCH 56/68] Update install.sh --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index ab3a978..ad7af37 100755 --- a/install.sh +++ b/install.sh @@ -253,7 +253,7 @@ if [[ $(echo "${embedded}" | grep -i "^n") ]]; then if [[ $(echo "${meshbotservice}" | grep -i "^y") ]]; then # document the service install printf "To install the %s service and keep notes, copy and paste the following commands:\n\n" "$service" - printf "sudo cp /opt/meshing-around/%s.service /etc/systemd/system/%s.service\n" "$service" "$service" + printf "sudo cp /opt/meshing-around/etc/%s.service /etc/systemd/system/etc/%s.service\n" "$service" "$service" printf "sudo systemctl daemon-reload\n" printf "sudo systemctl enable %s.service\n" "$service" printf "sudo systemctl start %s.service\n" "$service" From dae2e4c4f4e8a52968e6ea956b04e5a2aec5a669 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Fri, 3 Jan 2025 23:48:44 -0800 Subject: [PATCH 57/68] enhance embedded --- install.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index ad7af37..04cca4e 100755 --- a/install.sh +++ b/install.sh @@ -93,7 +93,6 @@ printf "\nConfig files generated!\n" # update lat,long in config.ini latlong=$(curl --silent --max-time 20 https://ipinfo.io/loc || echo "48.50,-123.0") IFS=',' read -r lat lon <<< "$latlong" -echo "lat: $lat, lon: $lon" sed -i "s|lat = 48.50|lat = $lat|g" config.ini sed -i "s|lon = -123.0|lon = $lon|g" config.ini echo "lat,long updated in config.ini to $latlong" @@ -253,7 +252,7 @@ if [[ $(echo "${embedded}" | grep -i "^n") ]]; then if [[ $(echo "${meshbotservice}" | grep -i "^y") ]]; then # document the service install printf "To install the %s service and keep notes, copy and paste the following commands:\n\n" "$service" - printf "sudo cp /opt/meshing-around/etc/%s.service /etc/systemd/system/etc/%s.service\n" "$service" "$service" + printf "sudo cp %s/etc/%s.service /etc/systemd/system/etc/%s.service\n" "$program_path" "$service" "$service" printf "sudo systemctl daemon-reload\n" printf "sudo systemctl enable %s.service\n" "$service" printf "sudo systemctl start %s.service\n" "$service" @@ -284,7 +283,7 @@ else printf "\nConfig file updated for embedded\n" # Set up the meshing around service - sudo cp /opt/meshing-around/$service.service /etc/systemd/system/$service.service + sudo cp /opt/meshing-around/etc/$service.service /etc/systemd/system/$service.service sudo systemctl daemon-reload sudo systemctl enable $service.service sudo systemctl start $service.service From 772218d1086e2c5f94e1c9955b75d7c54c3ae691 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Sat, 4 Jan 2025 00:04:28 -0800 Subject: [PATCH 58/68] Update install.sh --- install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/install.sh b/install.sh index 04cca4e..648e515 100755 --- a/install.sh +++ b/install.sh @@ -178,6 +178,7 @@ fi if [[ $(echo "${meshbotservice}" | grep -i "^y") ]] || [[ $(echo "${embedded}" | grep -i "^y") ]]; then sudo useradd -M meshbot sudo usermod -L meshbot + groupadd meshbot whoami="meshbot" echo "Added user meshbot with no home directory" sudo usermod -a -G dialout $whoami From 3b4b0e8c32ec127b6260cc7469f1312a2136397d Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Sat, 4 Jan 2025 00:04:57 -0800 Subject: [PATCH 59/68] Update install.sh --- install.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 648e515..311b130 100755 --- a/install.sh +++ b/install.sh @@ -178,7 +178,8 @@ fi if [[ $(echo "${meshbotservice}" | grep -i "^y") ]] || [[ $(echo "${embedded}" | grep -i "^y") ]]; then sudo useradd -M meshbot sudo usermod -L meshbot - groupadd meshbot + sudo groupadd meshbot + sudo usermod -a -G meshbot meshbot whoami="meshbot" echo "Added user meshbot with no home directory" sudo usermod -a -G dialout $whoami From 05476c2bffc8c0a60345938d3ea8abf69c612360 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Sat, 4 Jan 2025 12:51:04 -0800 Subject: [PATCH 60/68] Update install.sh --- install.sh | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/install.sh b/install.sh index 311b130..f019712 100755 --- a/install.sh +++ b/install.sh @@ -254,15 +254,15 @@ if [[ $(echo "${embedded}" | grep -i "^n") ]]; then if [[ $(echo "${meshbotservice}" | grep -i "^y") ]]; then # document the service install printf "To install the %s service and keep notes, copy and paste the following commands:\n\n" "$service" - printf "sudo cp %s/etc/%s.service /etc/systemd/system/etc/%s.service\n" "$program_path" "$service" "$service" - printf "sudo systemctl daemon-reload\n" - printf "sudo systemctl enable %s.service\n" "$service" - printf "sudo systemctl start %s.service\n" "$service" - printf "sudo systemctl status %s.service\n\n" "$service" - printf "To see logs and stop the service:\n" - printf "sudo journalctl -u %s.service\n" "$service" - printf "sudo systemctl stop %s.service\n" "$service" - printf "sudo systemctl disable %s.service\n" "$service" + printf "sudo cp %s/etc/%s.service /etc/systemd/system/etc/%s.service\n" "$program_path" "$service" "$service" > install_notes.txt + printf "sudo systemctl daemon-reload\n" >> install_notes.txt + printf "sudo systemctl enable %s.service\n" "$service" >> install_notes.txt + printf "sudo systemctl start %s.service\n" "$service" >> install_notes.txt + printf "sudo systemctl status %s.service\n\n" "$service" >> install_notes.txt + printf "To see logs and stop the service:\n" >> install_notes.txt + printf "sudo journalctl -u %s.service\n" "$service" >> install_notes.txt + printf "sudo systemctl stop %s.service\n" "$service" >> install_notes.txt + printf "sudo systemctl disable %s.service\n" "$service" >> install_notes.txt fi if [[ $(echo "${venv}" | grep -i "^y") ]]; then @@ -290,12 +290,12 @@ else sudo systemctl enable $service.service sudo systemctl start $service.service - printf "sudo systemctl status %s.service\n\n" "$service" + printf "sudo systemctl status %s.service\n\n" "$service" > install_notes.txt printf "To see logs and stop the service:\n" - printf "sudo journalctl -u %s.service\n" "$service" - printf "sudo systemctl stop %s.service\n" "$service" - printf "sudo systemctl disable %s.service\n" "$service" - read -p "Press enter to complete the installation" + printf "sudo journalctl -u %s.service\n" "$service" >> install_notes.txt + printf "sudo systemctl stop %s.service\n" "$service" >> install_notes.txt + printf "sudo systemctl disable %s.service\n" "$service" >> install_notes.txt + read -p "Press enter to complete the installation, these commands saved to install_notes.txt" fi printf "\nInstallation complete!\n" From 81e91ab6c5470fd09399e582481250aab3e91e80 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Sat, 4 Jan 2025 12:53:50 -0800 Subject: [PATCH 61/68] Update install.sh --- install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index f019712..bcb515c 100755 --- a/install.sh +++ b/install.sh @@ -251,7 +251,7 @@ if [[ $(echo "${embedded}" | grep -i "^n") ]]; then fi fi - if [[ $(echo "${meshbotservice}" | grep -i "^y") ]]; then + if [[ $(echo "${embedded}" | grep -i "^n") ]]; then # document the service install printf "To install the %s service and keep notes, copy and paste the following commands:\n\n" "$service" printf "sudo cp %s/etc/%s.service /etc/systemd/system/etc/%s.service\n" "$program_path" "$service" "$service" > install_notes.txt @@ -259,7 +259,7 @@ if [[ $(echo "${embedded}" | grep -i "^n") ]]; then printf "sudo systemctl enable %s.service\n" "$service" >> install_notes.txt printf "sudo systemctl start %s.service\n" "$service" >> install_notes.txt printf "sudo systemctl status %s.service\n\n" "$service" >> install_notes.txt - printf "To see logs and stop the service:\n" >> install_notes.txt + printf "To see logs and stop the service:\n" printf "sudo journalctl -u %s.service\n" "$service" >> install_notes.txt printf "sudo systemctl stop %s.service\n" "$service" >> install_notes.txt printf "sudo systemctl disable %s.service\n" "$service" >> install_notes.txt From 638dc4df166b783024571c7de659b3eb0d20c192 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Sat, 4 Jan 2025 12:54:45 -0800 Subject: [PATCH 62/68] Update install.sh --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index bcb515c..0cac656 100755 --- a/install.sh +++ b/install.sh @@ -295,8 +295,8 @@ else printf "sudo journalctl -u %s.service\n" "$service" >> install_notes.txt printf "sudo systemctl stop %s.service\n" "$service" >> install_notes.txt printf "sudo systemctl disable %s.service\n" "$service" >> install_notes.txt - read -p "Press enter to complete the installation, these commands saved to install_notes.txt" fi +read -p "Press enter to complete the installation, these commands saved to install_notes.txt" printf "\nInstallation complete!\n" From 858bef77034624e32b69c130b26d5703b328ce7d Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Sat, 4 Jan 2025 18:48:20 -0800 Subject: [PATCH 63/68] enhance --- install.sh | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/install.sh b/install.sh index 0cac656..77ff0c1 100755 --- a/install.sh +++ b/install.sh @@ -157,10 +157,17 @@ else fi fi -printf "\n\n" -echo "Which bot do you want to install as a service? Pong Mesh or None? (pong/mesh/n)" -echo "Pong bot is a simple bot for network testing, Mesh bot is a more complex bot more suited for meshing around" -read bot +# if $1 is passed +if [[ $1 == "mesh" ]]; then + bot="mesh" +elif [[ $1 == "pong" ]]; then + bot="pong" +else + printf "\n\n" + echo "Which bot do you want to install as a service? Pong Mesh or None? (pong/mesh/n)" + echo "Pong bot is a simple bot for network testing, Mesh bot is a more complex bot more suited for meshing around" + read bot +fi # set the correct path in the service file replace="s|/dir/|$program_path/|g" @@ -253,22 +260,24 @@ if [[ $(echo "${embedded}" | grep -i "^n") ]]; then if [[ $(echo "${embedded}" | grep -i "^n") ]]; then # document the service install - printf "To install the %s service and keep notes, copy and paste the following commands:\n\n" "$service" - printf "sudo cp %s/etc/%s.service /etc/systemd/system/etc/%s.service\n" "$program_path" "$service" "$service" > install_notes.txt + printf "To install the %s service and keep notes, reference following commands:\n\n" "$service" > install_notes.txt + printf "sudo cp %s/etc/%s.service /etc/systemd/system/etc/%s.service\n" "$program_path" "$service" "$service" >> install_notes.txt printf "sudo systemctl daemon-reload\n" >> install_notes.txt printf "sudo systemctl enable %s.service\n" "$service" >> install_notes.txt printf "sudo systemctl start %s.service\n" "$service" >> install_notes.txt printf "sudo systemctl status %s.service\n\n" "$service" >> install_notes.txt - printf "To see logs and stop the service:\n" + printf "To see logs and stop the service:\n" >> install_notes.txt printf "sudo journalctl -u %s.service\n" "$service" >> install_notes.txt printf "sudo systemctl stop %s.service\n" "$service" >> install_notes.txt printf "sudo systemctl disable %s.service\n" "$service" >> install_notes.txt fi if [[ $(echo "${venv}" | grep -i "^y") ]]; then - printf "\nFor running on venv, virtual launch bot with './launch.sh mesh' in path $program_path\n" + printf "\nFor running on venv, virtual launch bot with './launch.sh mesh' in path $program_path\n" >> install_notes.txt fi + read -p "Press enter to complete the installation, these commands saved to install_notes.txt" + printf "\nGood time to reboot? (y/n)" read reboot if [[ $(echo "${reboot}" | grep -i "^y") ]]; then @@ -289,14 +298,13 @@ else sudo systemctl daemon-reload sudo systemctl enable $service.service sudo systemctl start $service.service - + printf "Reference following commands:\n\n" "$service" > install_notes.txt printf "sudo systemctl status %s.service\n\n" "$service" > install_notes.txt printf "To see logs and stop the service:\n" printf "sudo journalctl -u %s.service\n" "$service" >> install_notes.txt printf "sudo systemctl stop %s.service\n" "$service" >> install_notes.txt printf "sudo systemctl disable %s.service\n" "$service" >> install_notes.txt fi -read -p "Press enter to complete the installation, these commands saved to install_notes.txt" printf "\nInstallation complete!\n" From 0d9245d448a163dd5504e635b08ab2da05d97912 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Sat, 4 Jan 2025 18:49:37 -0800 Subject: [PATCH 64/68] Update install.sh --- install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 77ff0c1..c37394a 100755 --- a/install.sh +++ b/install.sh @@ -299,8 +299,8 @@ else sudo systemctl enable $service.service sudo systemctl start $service.service printf "Reference following commands:\n\n" "$service" > install_notes.txt - printf "sudo systemctl status %s.service\n\n" "$service" > install_notes.txt - printf "To see logs and stop the service:\n" + printf "sudo systemctl status %s.service\n\n" "$service" >> install_notes.txt + printf "To see logs and stop the service:\n" >> install_notes.txt printf "sudo journalctl -u %s.service\n" "$service" >> install_notes.txt printf "sudo systemctl stop %s.service\n" "$service" >> install_notes.txt printf "sudo systemctl disable %s.service\n" "$service" >> install_notes.txt From b1155dea7d9944bca27ad4e89aff22341cee9452 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Sat, 4 Jan 2025 21:34:28 -0800 Subject: [PATCH 65/68] Update install.sh --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index c37394a..6c35229 100755 --- a/install.sh +++ b/install.sh @@ -37,7 +37,7 @@ if [[ $(hostname) == "femtofox" ]]; then embedded="y" else # check if running on embedded - printf "\nAre You installing into an embedded system like a luckfox? (y/n)" + printf "\nAre You installing into an embedded system like a luckfox? most should say no here (y/n)" read embedded fi From e24c9a9d561cf1e2342295cd2a957e42634114b3 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Sun, 5 Jan 2025 11:49:37 -0800 Subject: [PATCH 66/68] Update install.sh --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 6c35229..36aeb97 100755 --- a/install.sh +++ b/install.sh @@ -37,7 +37,7 @@ if [[ $(hostname) == "femtofox" ]]; then embedded="y" else # check if running on embedded - printf "\nAre You installing into an embedded system like a luckfox? most should say no here (y/n)" + printf "\nAre You installing into an embedded system like a luckfox or -native? most should say no here (y/n)" read embedded fi From 36ba04a234d89a2debbc11a463f4b4b973a31189 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Sun, 5 Jan 2025 15:33:24 -0800 Subject: [PATCH 67/68] Update locationdata.py --- modules/locationdata.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/locationdata.py b/modules/locationdata.py index 421c821..1594caf 100644 --- a/modules/locationdata.py +++ b/modules/locationdata.py @@ -357,11 +357,16 @@ def getWeatherAlertsNOAA(lat=0, lon=0, useDefaultLatLon=False): alerts = "" alertxml = xml.dom.minidom.parseString(alert_data.text) - + #old for i in alertxml.getElementsByTagName("entry"): alerts += ( i.getElementsByTagName("title")[0].childNodes[0].nodeValue + "\n" ) + #new + # for i in alertxml.getElementsByTagName("entry"): + # title = i.getElementsByTagName("title")[0].childNodes[0].nodeValue + # area_desc = i.getElementsByTagName("cap:areaDesc")[0].childNodes[0].nodeValue + # alerts += f"{title}\nArea: {area_desc}\n\n" if alerts == "" or alerts == None: return NO_ALERTS From 6c9f9f252126754bba135aa77aa07759be8ffb72 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Sun, 5 Jan 2025 18:11:57 -0800 Subject: [PATCH 68/68] Update config.template --- config.template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.template b/config.template index d69aa4d..bd5cac3 100644 --- a/config.template +++ b/config.template @@ -92,7 +92,7 @@ emailSentryAlerts = False # 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 +SentryChannel = 2 # holdoff time multiplied by seconds(20) of the watchdog SentryHoldoff = 9 # list of ignored nodes numbers ex: 2813308004,4258675309