mirror of
https://github.com/l5yth/potato-mesh.git
synced 2026-03-28 17:42:48 +01:00
Update default site configuration environment values (#288)
This commit is contained in:
@@ -29,7 +29,7 @@ against the web API.
|
||||
|
||||
```env
|
||||
API_TOKEN=replace-with-a-strong-token
|
||||
SITE_NAME=My Meshtastic Network
|
||||
SITE_NAME=PotatoMesh Demo
|
||||
MESH_SERIAL=/dev/ttyACM0
|
||||
```
|
||||
|
||||
|
||||
14
Dockerfile
14
Dockerfile
@@ -70,13 +70,13 @@ ENV APP_ENV=production \
|
||||
DB_BUSY_MAX_RETRIES=5 \
|
||||
DB_BUSY_RETRY_DELAY=0.05 \
|
||||
MAX_JSON_BODY_BYTES=1048576 \
|
||||
SITE_NAME="Berlin Mesh Network" \
|
||||
DEFAULT_CHANNEL="#MediumFast" \
|
||||
DEFAULT_FREQUENCY="868MHz" \
|
||||
MAP_CENTER_LAT=52.502889 \
|
||||
MAP_CENTER_LON=13.404194 \
|
||||
MAX_NODE_DISTANCE_KM=50 \
|
||||
MATRIX_ROOM="" \
|
||||
SITE_NAME="PotatoMesh Demo" \
|
||||
DEFAULT_CHANNEL="#LongFast" \
|
||||
DEFAULT_FREQUENCY="915MHz" \
|
||||
MAP_CENTER_LAT=38.761944 \
|
||||
MAP_CENTER_LON=-27.090833 \
|
||||
MAX_NODE_DISTANCE_KM=42 \
|
||||
MATRIX_ROOM="#potatomesh:dod.ngo" \
|
||||
DEBUG=0
|
||||
|
||||
# Start the application
|
||||
|
||||
14
README.md
14
README.md
@@ -69,12 +69,12 @@ exec ruby app.rb -p 41447 -o 0.0.0.0
|
||||
|
||||
The web app can be configured with environment variables (defaults shown):
|
||||
|
||||
* `SITE_NAME` - title and header shown in the ui (default: "Meshtastic Berlin")
|
||||
* `DEFAULT_CHANNEL` - default channel shown in the ui (default: "#MediumFast")
|
||||
* `DEFAULT_FREQUENCY` - default channel shown in the ui (default: "868MHz")
|
||||
* `MAP_CENTER_LAT` / `MAP_CENTER_LON` - default map center coordinates (default: `52.502889` / `13.404194`)
|
||||
* `MAX_NODE_DISTANCE_KM` - hide nodes farther than this distance from the center (default: `137`)
|
||||
* `MATRIX_ROOM` - matrix room id for a footer link (default: `#meshtastic-berlin:matrix.org`)
|
||||
* `SITE_NAME` - title and header shown in the UI (default: "PotatoMesh Demo")
|
||||
* `DEFAULT_CHANNEL` - default channel shown in the UI (default: "#LongFast")
|
||||
* `DEFAULT_FREQUENCY` - default frequency shown in the UI (default: "915MHz")
|
||||
* `MAP_CENTER_LAT` / `MAP_CENTER_LON` - default map center coordinates (default: `38.761944` / `-27.090833`)
|
||||
* `MAX_NODE_DISTANCE_KM` - hide nodes farther than this distance from the center (default: `42`)
|
||||
* `MATRIX_ROOM` - matrix room id for a footer link (default: `#potatomesh:dod.ngo`)
|
||||
* `PRIVATE` - set to `1` to hide the chat UI, disable message APIs, and exclude hidden clients (default: unset)
|
||||
* `PROM_REPORT_IDS` - comma-separated list of Node IDs to report in prometheus metrics, `*` for all (default: unset)
|
||||
|
||||
@@ -85,7 +85,7 @@ logo for Open Graph and Twitter cards.
|
||||
Example:
|
||||
|
||||
```bash
|
||||
SITE_NAME="Meshtastic Berlin" MAP_CENTER_LAT=52.502889 MAP_CENTER_LON=13.404194 MAX_NODE_DISTANCE_KM=137 MATRIX_ROOM="#meshtastic-berlin:matrix.org" ./app.sh
|
||||
SITE_NAME="PotatoMesh Demo" MAP_CENTER_LAT=38.761944 MAP_CENTER_LON=-27.090833 MAX_NODE_DISTANCE_KM=42 MATRIX_ROOM="#potatomesh:dod.ngo" ./app.sh
|
||||
```
|
||||
|
||||
### API
|
||||
|
||||
14
configure.sh
14
configure.sh
@@ -67,13 +67,13 @@ update_env() {
|
||||
}
|
||||
|
||||
# Get current values from .env if they exist
|
||||
SITE_NAME=$(grep "^SITE_NAME=" .env 2>/dev/null | cut -d'=' -f2- | tr -d '"' || echo "My Meshtastic Network")
|
||||
DEFAULT_CHANNEL=$(grep "^DEFAULT_CHANNEL=" .env 2>/dev/null | cut -d'=' -f2- | tr -d '"' || echo "#MediumFast")
|
||||
DEFAULT_FREQUENCY=$(grep "^DEFAULT_FREQUENCY=" .env 2>/dev/null | cut -d'=' -f2- | tr -d '"' || echo "868MHz")
|
||||
MAP_CENTER_LAT=$(grep "^MAP_CENTER_LAT=" .env 2>/dev/null | cut -d'=' -f2- | tr -d '"' || echo "52.502889")
|
||||
MAP_CENTER_LON=$(grep "^MAP_CENTER_LON=" .env 2>/dev/null | cut -d'=' -f2- | tr -d '"' || echo "13.404194")
|
||||
MAX_NODE_DISTANCE_KM=$(grep "^MAX_NODE_DISTANCE_KM=" .env 2>/dev/null | cut -d'=' -f2- | tr -d '"' || echo "50")
|
||||
MATRIX_ROOM=$(grep "^MATRIX_ROOM=" .env 2>/dev/null | cut -d'=' -f2- | tr -d '"' || echo "")
|
||||
SITE_NAME=$(grep "^SITE_NAME=" .env 2>/dev/null | cut -d'=' -f2- | tr -d '"' || echo "PotatoMesh Demo")
|
||||
DEFAULT_CHANNEL=$(grep "^DEFAULT_CHANNEL=" .env 2>/dev/null | cut -d'=' -f2- | tr -d '"' || echo "#LongFast")
|
||||
DEFAULT_FREQUENCY=$(grep "^DEFAULT_FREQUENCY=" .env 2>/dev/null | cut -d'=' -f2- | tr -d '"' || echo "915MHz")
|
||||
MAP_CENTER_LAT=$(grep "^MAP_CENTER_LAT=" .env 2>/dev/null | cut -d'=' -f2- | tr -d '"' || echo "38.761944")
|
||||
MAP_CENTER_LON=$(grep "^MAP_CENTER_LON=" .env 2>/dev/null | cut -d'=' -f2- | tr -d '"' || echo "-27.090833")
|
||||
MAX_NODE_DISTANCE_KM=$(grep "^MAX_NODE_DISTANCE_KM=" .env 2>/dev/null | cut -d'=' -f2- | tr -d '"' || echo "42")
|
||||
MATRIX_ROOM=$(grep "^MATRIX_ROOM=" .env 2>/dev/null | cut -d'=' -f2- | tr -d '"' || echo "#potatomesh:dod.ngo")
|
||||
API_TOKEN=$(grep "^API_TOKEN=" .env 2>/dev/null | cut -d'=' -f2- | tr -d '"' || echo "")
|
||||
POTATOMESH_IMAGE_ARCH=$(grep "^POTATOMESH_IMAGE_ARCH=" .env 2>/dev/null | cut -d'=' -f2- | tr -d '"' || echo "linux-amd64")
|
||||
|
||||
|
||||
@@ -3,13 +3,13 @@ x-web-base: &web-base
|
||||
environment:
|
||||
APP_ENV: ${APP_ENV:-production}
|
||||
RACK_ENV: ${RACK_ENV:-production}
|
||||
SITE_NAME: ${SITE_NAME:-My Meshtastic Network}
|
||||
DEFAULT_CHANNEL: ${DEFAULT_CHANNEL:-#MediumFast}
|
||||
DEFAULT_FREQUENCY: ${DEFAULT_FREQUENCY:-868MHz}
|
||||
MAP_CENTER_LAT: ${MAP_CENTER_LAT:-52.502889}
|
||||
MAP_CENTER_LON: ${MAP_CENTER_LON:-13.404194}
|
||||
MAX_NODE_DISTANCE_KM: ${MAX_NODE_DISTANCE_KM:-50}
|
||||
MATRIX_ROOM: ${MATRIX_ROOM:-}
|
||||
SITE_NAME: ${SITE_NAME:-PotatoMesh Demo}
|
||||
DEFAULT_CHANNEL: ${DEFAULT_CHANNEL:-#LongFast}
|
||||
DEFAULT_FREQUENCY: ${DEFAULT_FREQUENCY:-915MHz}
|
||||
MAP_CENTER_LAT: ${MAP_CENTER_LAT:-38.761944}
|
||||
MAP_CENTER_LON: ${MAP_CENTER_LON:--27.090833}
|
||||
MAX_NODE_DISTANCE_KM: ${MAX_NODE_DISTANCE_KM:-42}
|
||||
MATRIX_ROOM: ${MATRIX_ROOM:-#potatomesh:dod.ngo}
|
||||
API_TOKEN: ${API_TOKEN}
|
||||
DEBUG: ${DEBUG:-0}
|
||||
command: ["ruby", "app.rb", "-p", "41447", "-o", "0.0.0.0"]
|
||||
|
||||
@@ -71,13 +71,13 @@ ENV RACK_ENV=production \
|
||||
DB_BUSY_MAX_RETRIES=5 \
|
||||
DB_BUSY_RETRY_DELAY=0.05 \
|
||||
MAX_JSON_BODY_BYTES=1048576 \
|
||||
SITE_NAME="Berlin Mesh Network" \
|
||||
DEFAULT_CHANNEL="#MediumFast" \
|
||||
DEFAULT_FREQUENCY="868MHz" \
|
||||
MAP_CENTER_LAT=52.502889 \
|
||||
MAP_CENTER_LON=13.404194 \
|
||||
MAX_NODE_DISTANCE_KM=50 \
|
||||
MATRIX_ROOM="" \
|
||||
SITE_NAME="PotatoMesh Demo" \
|
||||
DEFAULT_CHANNEL="#LongFast" \
|
||||
DEFAULT_FREQUENCY="915MHz" \
|
||||
MAP_CENTER_LAT=38.761944 \
|
||||
MAP_CENTER_LON=-27.090833 \
|
||||
MAX_NODE_DISTANCE_KM=42 \
|
||||
MATRIX_ROOM="#potatomesh:dod.ngo" \
|
||||
DEBUG=0
|
||||
|
||||
# Start the application
|
||||
|
||||
18
web/app.rb
18
web/app.rb
@@ -228,10 +228,6 @@ def canonicalize_configured_instance_domain(raw)
|
||||
raise "INSTANCE_DOMAIN must be a bare hostname (optionally with a port) without schemes or paths: #{raw.inspect}"
|
||||
end
|
||||
|
||||
if (ip = ip_from_domain(sanitized))
|
||||
raise "INSTANCE_DOMAIN must resolve to a DNS hostname, not an IP address: #{sanitized}"
|
||||
end
|
||||
|
||||
sanitized.downcase
|
||||
end
|
||||
|
||||
@@ -583,13 +579,13 @@ get "/.well-known/potato-mesh" do
|
||||
send_file well_known_file_path
|
||||
end
|
||||
|
||||
SITE_NAME = fetch_config_string("SITE_NAME", "Meshtastic Berlin")
|
||||
DEFAULT_CHANNEL = fetch_config_string("DEFAULT_CHANNEL", "#MediumFast")
|
||||
DEFAULT_FREQUENCY = fetch_config_string("DEFAULT_FREQUENCY", "868MHz")
|
||||
MAP_CENTER_LAT = ENV.fetch("MAP_CENTER_LAT", "52.502889").to_f
|
||||
MAP_CENTER_LON = ENV.fetch("MAP_CENTER_LON", "13.404194").to_f
|
||||
MAX_NODE_DISTANCE_KM = ENV.fetch("MAX_NODE_DISTANCE_KM", "137").to_f
|
||||
MATRIX_ROOM = ENV.fetch("MATRIX_ROOM", "#meshtastic-berlin:matrix.org")
|
||||
SITE_NAME = fetch_config_string("SITE_NAME", "PotatoMesh Demo")
|
||||
DEFAULT_CHANNEL = fetch_config_string("DEFAULT_CHANNEL", "#LongFast")
|
||||
DEFAULT_FREQUENCY = fetch_config_string("DEFAULT_FREQUENCY", "915MHz")
|
||||
MAP_CENTER_LAT = ENV.fetch("MAP_CENTER_LAT", "38.761944").to_f
|
||||
MAP_CENTER_LON = ENV.fetch("MAP_CENTER_LON", "-27.090833").to_f
|
||||
MAX_NODE_DISTANCE_KM = ENV.fetch("MAX_NODE_DISTANCE_KM", "42").to_f
|
||||
MATRIX_ROOM = ENV.fetch("MATRIX_ROOM", "#potatomesh:dod.ngo")
|
||||
INSTANCE_DOMAIN, INSTANCE_DOMAIN_SOURCE = determine_instance_domain
|
||||
DEBUG = ENV["DEBUG"] == "1"
|
||||
|
||||
|
||||
@@ -16,10 +16,10 @@ export const DEFAULT_CONFIG = {
|
||||
refreshMs: 60_000,
|
||||
refreshIntervalSeconds: 60,
|
||||
chatEnabled: true,
|
||||
defaultChannel: '#MediumFast',
|
||||
defaultFrequency: '868MHz',
|
||||
mapCenter: { lat: 52.502889, lon: 13.404194 },
|
||||
maxNodeDistanceKm: 137,
|
||||
defaultChannel: '#LongFast',
|
||||
defaultFrequency: '915MHz',
|
||||
mapCenter: { lat: 38.761944, lon: -27.090833 },
|
||||
maxNodeDistanceKm: 42,
|
||||
tileFilters: {
|
||||
light: 'grayscale(1) saturate(0) brightness(0.92) contrast(1.05)',
|
||||
dark: 'grayscale(1) invert(1) brightness(0.9) contrast(1.08)'
|
||||
|
||||
@@ -281,13 +281,13 @@ RSpec.describe "Potato Mesh Sinatra app" do
|
||||
expect(source).to eq(:environment)
|
||||
end
|
||||
|
||||
it "rejects IP addresses configured via the environment" do
|
||||
ENV["INSTANCE_DOMAIN"] = "203.0.113.40"
|
||||
it "allows IP addresses configured via the environment" do
|
||||
ENV["INSTANCE_DOMAIN"] = "http://127.0.0.1"
|
||||
|
||||
expect { determine_instance_domain }.to raise_error(
|
||||
RuntimeError,
|
||||
/INSTANCE_DOMAIN must resolve to a DNS hostname/,
|
||||
)
|
||||
domain, source = determine_instance_domain
|
||||
|
||||
expect(domain).to eq("127.0.0.1")
|
||||
expect(source).to eq(:environment)
|
||||
end
|
||||
|
||||
it "rejects instance domains containing path components" do
|
||||
|
||||
Reference in New Issue
Block a user