From efc5381b807b55d73f3b5d47db86650f93540cc1 Mon Sep 17 00:00:00 2001 From: John Shuping Date: Thu, 8 Aug 2024 16:37:40 -0500 Subject: [PATCH] converts config to yaml --- .gitignore | 1 + README.md | 2 +- config.json.sample | 93 ------------------------------------------ config.py | 6 +-- config.yaml.sample | 82 +++++++++++++++++++++++++++++++++++++ docker-compose-dev.yml | 2 +- docker-compose.yml | 2 +- 7 files changed, 89 insertions(+), 99 deletions(-) delete mode 100644 config.json.sample create mode 100644 config.yaml.sample diff --git a/.gitignore b/.gitignore index 06231e4..784ddfd 100644 --- a/.gitignore +++ b/.gitignore @@ -15,4 +15,5 @@ output/* mosquitto/data/* postgres/data/* config.json +config.yaml spa diff --git a/README.md b/README.md index e4586fc..cf26d59 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ cd meshinfo ##### Edit Configuration -1. Copy and then edit the `config.json.sample` to `config.json`. +1. Copy and then edit the `config.yaml.sample` to `config.yaml`. 2. Edit the `Caddyfile` and be sure it is setup for your hostname (FQDN if requiring Let's Encrypt cert to be generated) and your email address for the TLS line. If you only wish to use a self-signed certificate (and are OK with the browser warnings about this), then change it from your email address to `tls internal`. 3. Edit the `docker-compose.yml` (or `docker-compose-dev.yml` if you are going to use that one) and adjust any port mappings for caddy if you wish to have it run on anything other than 80/443. Keep in mind that if you are not using a FQDN and ports 80/443, Caddy will fail to provision a Let's Encrypt certificate. This is because Let's Encrypt requires 80/443 to be accessible and this is not a limitation of Caddy nor MeshInfo. diff --git a/config.json.sample b/config.json.sample deleted file mode 100644 index 167a4b9..0000000 --- a/config.json.sample +++ /dev/null @@ -1,93 +0,0 @@ -{ - "mesh": { - "name": "Sac Valley Mesh", - "shortname": "SVM", - "description": "Serving Meshtastic to the Sacramento Valley and surrounding areas.", - "url": "https://sacvalleymesh.com", - "contact": "https://sacvalleymesh.com", - "country": "US", - "region": "California", - "metro": "Sacramento", - "latitude": 38.58, - "longitude": -121.49, - "altitude": 0, - "timezone": "America/Los_Angeles", - "announce": { - "enabled": true, - "interval": 60 - }, - "tools": [ - { "name": "Armooo's MeshView", "url": "https://meshview.armooo.net" }, - { "name": "Liam's Meshtastic Map", "url": "https://meshtastic.liamcottle.net" }, - { "name": "MeshMap", "url": "https://meshmap.net" }, - { "name": "Bay Mesh Explorer", "url": "https://app.bayme.sh" }, - { "name": "HWT Path Profiler", "url": "https://heywhatsthat.com/profiler.html" } - ] - }, - "broker": { - "enabled": true, - "host": "mqtt.meshtastic.org", - "port": 1883, - "username": "meshdev", - "password": "large4cats", - "client_id_prefix": "meshinfo-dev", - "topics": [ - "msh/US/CA/SacValley/#", - "msh/US/CA/sacvalley/#" - ], - "decoders": { - "protobuf": { "enabled": true }, - "json": { "enabled": true } - }, - "channels": { - "encryption": [ - { "key": "1PG7OiApB1nwvP+rz05pAQ==", "key_name": "Default" } - ], - "display": [ "0" ] - } - }, - "paths": { - "backups": "output/backups", - "data": "output/data", - "output": "output/static-html", - "templates": "templates" - }, - "server": { - "node_id": "4355f528", - "base_url": "REPLACE_WITH_THE_URL_OF_THIS_SERVER_WITHOUT_TRAILING_SLASH", - "node_activity_prune_threshold": 7200, - "timezone": "America/Los_Angeles", - "intervals": { - "data_save": 300, - "render": 5 - }, - "backups": { - "enabled": true, - "interval": 86400 - }, - "enrich": { - "enabled": true, - "interval": 900, - "provider": "world.meshinfo.network" - }, - "graph": { - "enabled": true, - "max_depth": 10 - } - }, - "integrations": { - "discord": { - "enabled": false, - "token": "REPLACE_WITH_TOKEN", - "guild": "REPLACE_WITH_GUILD_ID" - }, - "geocoding": { - "enabled": false, - "provider": "geocode.maps.co", - "geocode.maps.co": { - "api_key": "REPLACE_WITH_API_KEY" - } - } - }, - "debug": false -} diff --git a/config.py b/config.py index cddbcde..91795df 100644 --- a/config.py +++ b/config.py @@ -1,12 +1,12 @@ import datetime -import json import uuid +import yaml class Config: @classmethod def load(cls): - config = cls.load_from_file('config.json') + config = cls.load_from_file('config.yaml') random_uuid = str(uuid.uuid4()) config['broker']['client_id'] = config['broker']['client_id_prefix'] + '-' + random_uuid config['server']['start_time'] = datetime.datetime.now(datetime.timezone.utc).astimezone() @@ -23,4 +23,4 @@ def load(cls): @classmethod def load_from_file(cls, path): with open(path, 'r') as f: - return json.load(f) + return yaml.safe_load(f) diff --git a/config.yaml.sample b/config.yaml.sample new file mode 100644 index 0000000..291fce0 --- /dev/null +++ b/config.yaml.sample @@ -0,0 +1,82 @@ +mesh: + name: Sac Valley Mesh + shortname: SVM + description: Serving Meshtastic to the Sacramento Valley and surrounding areas. + url: https://sacvalleymesh.com + contact: https://sacvalleymesh.com + country: US + region: California + metro: Sacramento + latitude: 38.58 + longitude: -121.49 + altitude: 0 + timezone: America/Los_Angeles + announce: + enabled: true + interval: 60 + tools: + - name: Armooo's MeshView + url: https://meshview.armooo.net + - name: Liam's Meshtastic Map + url: https://meshtastic.liamcottle.net + - name: MeshMap + url: https://meshmap.net + - name: Bay Mesh Explorer + url: https://app.bayme.sh + - name: HWT Path Profiler + url: https://heywhatsthat.com/profiler.html +broker: + enabled: true + host: mqtt.meshtastic.org + port: 1883 + username: meshdev + password: large4cats + client_id_prefix: meshinfo-dev + topics: + - msh/US/CA/SacValley/# + - msh/US/CA/sacvalley/# + decoders: + protobuf: + enabled: true + json: + enabled: true + channels: + encryption: + - key: 1PG7OiApB1nwvP+rz05pAQ== + key_name: Default + display: + - '0' +paths: + backups: output/backups + data: output/data + output: output/static-html + templates: templates +server: + node_id: 4355f528 + base_url: REPLACE_WITH_THE_URL_OF_THIS_SERVER_WITHOUT_TRAILING_SLASH + node_activity_prune_threshold: 7200 + timezone: America/Los_Angeles + intervals: + data_save: 300 + render: 5 + backups: + enabled: true + interval: 86400 + enrich: + enabled: true + interval: 900 + provider: world.meshinfo.network + graph: + enabled: true + max_depth: 10 +integrations: + discord: + enabled: false + token: REPLACE_WITH_TOKEN + guild: REPLACE_WITH_GUILD_ID + geocoding: + enabled: false + provider: geocode.maps.co + geocode.maps.co: + api_key: REPLACE_WITH_API_KEY +debug: false diff --git a/docker-compose-dev.yml b/docker-compose-dev.yml index f14b1ee..dffc9b2 100644 --- a/docker-compose-dev.yml +++ b/docker-compose-dev.yml @@ -37,7 +37,7 @@ services: context: . dockerfile: Dockerfile volumes: - - ./config.json:/app/config.json + - ./config.yaml:/app/config.yaml - ./output:/app/output - ./templates:/app/templates - ./spa:/app/spa diff --git a/docker-compose.yml b/docker-compose.yml index 99a4763..1ad20cd 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -35,7 +35,7 @@ services: meshinfo: image: ghcr.io/meshaddicts/meshinfo:latest volumes: - - ./config.json:/app/config.json + - ./config.yaml:/app/config.yaml - ./output:/app/output environment: - PYTHONUNBUFFERED=1