mmrelaynode/app/command_wrapper.py

23 wiersze
679 B
Python
Czysty Zwykły widok Historia

2023-09-09 17:52:25 +00:00
import os
import subprocess
import time
def execute_meshtastic_command(options):
"""Execute a meshtastic command with the given options."""
2023-11-26 21:51:34 +00:00
command = ["meshtastic", "--host", "mmrelaydevice", "--port", "4403"] + options.split()
2023-09-09 17:52:25 +00:00
subprocess.run(command)
time.sleep(30) # Pause for 30 seconds
# Loop through environment variables in sequence
index = 1
while True:
command = os.environ.get(f'MESHTASTIC_COMMAND_{index}')
if command:
execute_meshtastic_command(command)
index += 1
else:
break
# Finally, run the main Meshtastic process (or whatever process you want to keep the container running)
subprocess.run(["meshtastic"])