setup.py.jinja 856 B

12345678910111213141516171819202122232425262728293031
  1. {% macro setup_py(values) -%}
  2. import sys
  3. sys.path.append('/tmp/python')
  4. from pathlib import Path
  5. import toml
  6. import os
  7. import io
  8. config_file_path = '/arti/arti.toml'
  9. Path(config_file_path).touch(exist_ok=True)
  10. os.chmod(config_file_path, 0o664)
  11. docker_host_ip = os.popen("getent hosts host.docker.internal").read().split()[0]
  12. arti_config = toml.load(config_file_path)
  13. arti_config['onion_services'] = {}
  14. {% for service in values.arti.hidden_services %}
  15. ip = '{{ service.ip }}' or docker_host_ip
  16. arti_config['onion_services']['{{ service.name }}'] = {}
  17. arti_config['onion_services']['{{ service.name }}']['proxy_ports'] = [
  18. ['{{ service.hidden_service_port }}', f'{ip}:{{ service.port }}'],
  19. ['*', 'destroy']
  20. ]
  21. {% endfor %}
  22. with open(config_file_path, 'w') as f:
  23. toml.dump(arti_config, f)
  24. print('Arti config updated successfully!')
  25. {%- endmacro %}