mirror of
https://github.com/SpudGunMan/meshing-around.git
synced 2026-06-25 12:31:08 +02:00
@@ -288,6 +288,7 @@ broadcastCh = 2,4
|
||||
enable_read_news = False
|
||||
news_file_path = news.txt
|
||||
news_random_line = False # only return a single random line from the news file
|
||||
enable_runShellCmd = False # enables running of bash commands runShell.sh demo for sysinfo
|
||||
```
|
||||
|
||||
#### Offline EAS
|
||||
|
||||
@@ -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_runShellCmd = False
|
||||
|
||||
[smtp]
|
||||
# enable or disable the SMTP module
|
||||
|
||||
+11
-3
@@ -769,7 +769,11 @@ def sysinfo(message, message_from_id, deviceID):
|
||||
if "?" in message:
|
||||
return "sysinfo command returns system information."
|
||||
else:
|
||||
return get_sysinfo(message_from_id, deviceID)
|
||||
if enable_runShellCmd and file_monitor_enabled:
|
||||
shellData = call_external_script(message)
|
||||
return get_sysinfo(message_from_id, deviceID) + "\n" + shellData
|
||||
else:
|
||||
return get_sysinfo(message_from_id, deviceID)
|
||||
|
||||
def handle_lheard(message, nodeid, deviceID, isDM):
|
||||
if "?" in message and isDM:
|
||||
@@ -1275,8 +1279,12 @@ async def start_rx():
|
||||
logger.debug(f"System: Radio Detection Enabled using rigctld at {rigControlServerAddress} brodcasting to channels: {sigWatchBroadcastCh} for {get_freq_common_name(get_hamlib('f'))}")
|
||||
if file_monitor_enabled:
|
||||
logger.debug(f"System: File Monitor Enabled for {file_monitor_file_path}, broadcasting to channels: {file_monitor_broadcastCh}")
|
||||
if read_news_enabled:
|
||||
logger.debug(f"System: File Monitor News Reader Enabled for {news_file_path}")
|
||||
if enable_runShellCmd:
|
||||
logger.debug(f"System: Shell Command monitor enabled")
|
||||
if read_news_enabled:
|
||||
logger.debug(f"System: File Monitor News Reader Enabled for {news_file_path}")
|
||||
if bee_enabled:
|
||||
logger.debug(f"System: File Monitor Bee Monitor Enabled for bee.txt")
|
||||
if wxAlertBroadcastEnabled:
|
||||
logger.debug(f"System: Weather Alert Broadcast Enabled on channels {wxAlertBroadcastChannel}")
|
||||
if emergencyAlertBrodcastEnabled:
|
||||
|
||||
+10
-4
@@ -63,12 +63,18 @@ async def watch_file():
|
||||
return content
|
||||
await asyncio.sleep(1) # Check every
|
||||
|
||||
def call_external_script(message):
|
||||
# Call an external script runShell.sh
|
||||
def call_external_script(message, script="runShell.sh"):
|
||||
try:
|
||||
output = os.popen(f"bash runShell.sh {message}").read()
|
||||
# Debugging: Print the current working directory and resolved script path
|
||||
current_working_directory = os.getcwd()
|
||||
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"
|
||||
output = os.popen(f"bash {script_path} {message}").read()
|
||||
return output
|
||||
except Exception as e:
|
||||
logger.warning(f"FileMon: Error calling external script")
|
||||
logger.warning(f"FileMon: Error calling external script: {e}")
|
||||
return None
|
||||
|
||||
@@ -542,9 +542,9 @@ def getIpawsAlert(lat=0, lon=0, shortAlerts = False):
|
||||
'geocode_value': geocode_value,
|
||||
'description': description
|
||||
})
|
||||
else:
|
||||
# these are discarded some day but logged for debugging currently
|
||||
logger.debug(f"Debug iPAWS: Type:{alertType} Code:{alertCode} Desc:{areaDesc} GeoType:{geocode_type} GeoVal:{geocode_value}, Headline:{headline}")
|
||||
# else:
|
||||
# # these are discarded some day but logged for debugging currently
|
||||
# logger.debug(f"Debug iPAWS: Type:{alertType} Code:{alertCode} Desc:{areaDesc} GeoType:{geocode_type} GeoVal:{geocode_value}, Headline:{headline}")
|
||||
|
||||
# return the numWxAlerts of alerts
|
||||
if len(alerts) > 0:
|
||||
|
||||
@@ -222,6 +222,7 @@ try:
|
||||
read_news_enabled = config['fileMon'].getboolean('enable_read_news', False) # default disabled
|
||||
news_file_path = config['fileMon'].get('news_file_path', 'news.txt') # default news.txt
|
||||
news_random_line_only = config['fileMon'].getboolean('news_random_line', False) # default False
|
||||
enable_runShellCmd = config['fileMon'].getboolean('enable_runShellCmd', False) # default False
|
||||
|
||||
# games
|
||||
game_hop_limit = config['messagingSettings'].getint('game_hop_limit', 5) # default 3 hops
|
||||
|
||||
+3
-4
@@ -100,10 +100,6 @@ if dad_jokes_enabled:
|
||||
from modules.games.joke import * # from the spudgunman/meshing-around repo
|
||||
trap_list = trap_list + ("joke",)
|
||||
help_message = help_message + ", joke"
|
||||
|
||||
# Bee Configuration
|
||||
if bee_enabled:
|
||||
trap_list = trap_list + ("🐝",)
|
||||
|
||||
# Wikipedia Search Configuration
|
||||
if wikipedia_enabled:
|
||||
@@ -199,6 +195,9 @@ if file_monitor_enabled or read_news_enabled:
|
||||
if read_news_enabled:
|
||||
trap_list = trap_list + trap_list_filemon # items readnews
|
||||
help_message = help_message + ", readnews"
|
||||
# Bee Configuration uses file monitor module
|
||||
if bee_enabled:
|
||||
trap_list = trap_list + ("🐝",)
|
||||
|
||||
# clean up the help message
|
||||
help_message = help_message.split(", ")
|
||||
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
# meshing-around demo script for shell scripting
|
||||
# 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}')
|
||||
|
||||
# if command vcgencmd is found
|
||||
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
|
||||
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"
|
||||
printf "RAM Usage: %.2f%%\n" "$ram_usage"
|
||||
printf "Temperature: %.1f°C (%.1f°F)\n" "$temp" "$tempf"
|
||||
Reference in New Issue
Block a user