-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstart_multiplexer.py
More file actions
40 lines (28 loc) · 949 Bytes
/
start_multiplexer.py
File metadata and controls
40 lines (28 loc) · 949 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python3
import os
import json
TTN_CONF_FILE = '/var/nebra/ttn_conf.json'
def read_ttn_config():
try:
with open(TTN_CONF_FILE) as file_:
ttn_config = json.loads(file_.read())
return ttn_config
except FileNotFoundError:
# Config file doesn't exist yet, assume TTN not enabled.
return {
'ttn_enabled': False,
'ttn_cluster': 'eu'
}
def main():
bin = '/usr/local/bin/gwmp-mux'
cmd = '%s --client helium-miner:1680' % bin
ttn_config = read_ttn_config()
if ttn_config.get('ttn_enabled', False):
ttn_cluster = ttn_config.get('ttn_cluster')
cmd += ' --client %s:1700' % ttn_cluster
fleet_name = os.environ.get('BALENA_APP_NAME')
if fleet_name.endswith('-c') and os.path.isfile('/var/thix/config.yaml'):
cmd += ' --client thix-forwarder:1680'
os.system(cmd)
if __name__ == '__main__':
main()