From b154e0017268ea849ec68dc6ddaf1aff8ee14211 Mon Sep 17 00:00:00 2001 From: Astro Date: Tue, 22 Feb 2022 00:16:52 +0100 Subject: [PATCH] sdrweb: use dump1090 json dumps for adsb.html --- hosts/containers/sdrweb/adsb.html | 12 +++++----- hosts/containers/sdrweb/default.nix | 4 ++-- hosts/radiobert/adsb.nix | 34 ++++++++++++----------------- 3 files changed, 22 insertions(+), 28 deletions(-) diff --git a/hosts/containers/sdrweb/adsb.html b/hosts/containers/sdrweb/adsb.html index 47c00e74..3e7be5a2 100644 --- a/hosts/containers/sdrweb/adsb.html +++ b/hosts/containers/sdrweb/adsb.html @@ -51,7 +51,7 @@ var maxalt = 40000; /* Max altitude in the average case */ var selected = (Selected == plane.hex); - b = 0.5 + (0.5*plane.altitude/maxalt); + b = 0.5 + (0.5 * plane.alt_baro / maxalt); /* As Icon we use the plane emoji, this is a simple solution but is definitely a compromise: we expect the icon to be rotated @@ -115,10 +115,10 @@ } function fetchData() { - $.getJSON('/data.json', function(data) { + $.getJSON('/aircraft.json', function(data) { var stillhere = {} - for (var j=0; j < data.length; j++) { - var plane = data[j]; + for (var j=0; j < data.aircraft.length; j++) { + var plane = data.aircraft[j]; var marker = null; stillhere[plane.hex] = true; plane.flight = $.trim(plane.flight); @@ -157,7 +157,7 @@ Planes[plane.hex] = plane; } } - NumPlanes = data.length; + NumPlanes = data.aircraft.length; /* Remove idle planes. */ for (var p in Planes) { @@ -171,7 +171,7 @@ refreshGeneralInfo(); }).always(function() { - setTimeout(fetchData, 500); + setTimeout(fetchData, 1000); }); } diff --git a/hosts/containers/sdrweb/default.nix b/hosts/containers/sdrweb/default.nix index 6ca1c081..700f59c6 100644 --- a/hosts/containers/sdrweb/default.nix +++ b/hosts/containers/sdrweb/default.nix @@ -40,8 +40,8 @@ index index.html; charset utf-8; ''; - locations."/data.json" = { - proxyPass = "http://${config.c3d2.hosts.radiobert.ip4}:8080/data.json"; + locations."/aircraft.json" = { + proxyPass = "http://radiobert.serv.zentralwerk.org/aircraft.json"; }; }; }; diff --git a/hosts/radiobert/adsb.nix b/hosts/radiobert/adsb.nix index 8048cfd5..74f2dec2 100644 --- a/hosts/radiobert/adsb.nix +++ b/hosts/radiobert/adsb.nix @@ -1,4 +1,4 @@ -{ config, pkgs, ... }: +{ config, pkgs, lib, ... }: let lat = "51.081"; @@ -69,25 +69,6 @@ in { verifyPeer = false; }; }; - - users.users.sbs2json = { - isSystemUser = true; - group = "adsb"; - }; - systemd.services.sbs2json = { - wantedBy = [ "multi-user.target" ]; - requires = [ "dump1090.service" ]; - serviceConfig = { - ExecStart = "${pkgs.heliwatch.http-json}/bin/http-json"; - User = "sbs2json"; - Group = "adsb"; - ProtectSystem = "full"; - ProtectHome = true; - Restart = "always"; - RestartSec = "10s"; - }; - }; - systemd.services.feed-chaos-consulting = { wantedBy = [ "multi-user.target" ]; requires = [ "sbs2json.service" ]; @@ -136,6 +117,19 @@ in { Exec "${config.services.collectd.user}" "${pkgs.heliwatch.collectd-stats}/bin/collectd-stats" ''; + # serve dump1090 json data via http + services.nginx = { + enable = true; + virtualHosts."radiobert.serv.zentralwerk.org" = { + default = true; + root = statsDir; + extraConfig = '' + autoindex on; + ''; + }; + }; + systemd.services.nginx.serviceConfig.PrivateTmp = lib.mkForce false; + environment.systemPackages = with pkgs; [ dump1090 #dump1090_rs