diff --git a/hosts/containers/freifunk/assets/sysinfo-json.cgi b/hosts/containers/freifunk/assets/sysinfo-json.cgi deleted file mode 100644 index 92dff0ae..00000000 --- a/hosts/containers/freifunk/assets/sysinfo-json.cgi +++ /dev/null @@ -1,50 +0,0 @@ -{ - "version": "15", - "timestamp": "1586882346", - "data": { - "firmware": { - "version": "0.0.0", - "DISTRIB_ID": "NixOS", - "DISTRIB_RELEASE": "20.03", - "DISTRIB_REVISION": "", - "DISTRIB_CODENAME": "", - "DISTRIB_TARGET": "x86_64", - "DISTRIB_DESCRIPTION": "NixOS 20.03" - }, - "system": { - "uptime": "0 0", - "uname": "Linux 5.3.18", - "nameserver": [ - ], - "date": "Tue Apr 14 18:39:06 CEST 2020", - "cpuinfo": "Intel(R) Xeon(R) CPU E5-2680 v2 @ 2.80GHz", - "cpucount": "40", - "bmxd": "bmxd", - "essid": "ZW public", - "node_type": "router", - "splash": 0, - "email_notification": 0, - "autoupdate": 0, - "available_flash_size": "16T", - "bmxd_restart_counter": 0 - }, - "common": { - "city": "Dresden", - "node": "51073", - "domain": "freifunk-dresden.de", - "ip": "10.200.200.74", - "network_id": "1206" - }, - "gps": { - "latitude": 51.0810624, - "longitude": 13.7285866, - "altitude": 100 - }, - "contact": { - "name": "C3D2", - "location": "Zentralwerk Haus B Souterrain", - "email": "astro%40spaceboyz.net", - "note": "" - } - } -} diff --git a/hosts/containers/freifunk/configuration.nix b/hosts/containers/freifunk/configuration.nix index 2f14142a..478ef0c5 100644 --- a/hosts/containers/freifunk/configuration.nix +++ b/hosts/containers/freifunk/configuration.nix @@ -11,6 +11,10 @@ let ddmeshNode = 51073; ddmeshAddrPart = "200.74"; rt_table = 7; + bmxd = import (toString ) { inherit pkgs; }; + sysinfo-json = import { + inherit pkgs bmxd ddmeshNode; + }; in { imports = [ @@ -113,10 +117,7 @@ in { }; }; }; - systemd.services.bmxd = - let - bmxd = import (toString ) { inherit pkgs; }; - in { + systemd.services.bmxd = { after = [ "systemd-networkd.service" ]; wantedBy = [ "network.target" ]; serviceConfig = { @@ -148,6 +149,17 @@ in { wantedBy = [ "timers.target" ]; timerConfig.OnCalendar = "daily"; }; + systemd.services.sysinfo-json = { + script = '' + ${sysinfo-json}/bin/bmxddump.sh + ${sysinfo-json}/bin/sysinfo-json.cgi > /tmp/sysinfo.json + ''; + }; + systemd.timers.sysinfo-json = { + partOf = [ "sysinfo-json.service" ]; + wantedBy = [ "timers.target" ]; + timerConfig.OnCalendar = "minutely"; + }; services.bird2 = { enable = true; @@ -202,47 +214,53 @@ in { recommendedOptimisation = true; recommendedGzipSettings = true; - virtualHosts = - let - aliasFile = path: { - alias = path; - extraConfig = '' - etag off; - add_header etag "\"${builtins.substring 11 32 path}\""; - ''; - }; - in { - "c3d2.ffdd" = { - default = true; - root = ; - locations = { - "/".index = "index.html"; - "/sysinfo-json.cgi".extraConfig = '' + virtualHosts = { + "c3d2.ffdd" = { + default = true; + root = ; + locations = { + "/" = { + index = "index.html"; + extraConfig = '' + etag off; + add_header etag "\"${builtins.substring 11 32 ( + "/assets")}\""; + ''; + }; + "=/sysinfo-json.cgi" = { + alias = "/tmp/sysinfo.json"; + extraConfig = '' + add_header Content-Type "application/json;charset=UTF-8"; + ''; + }; + "=/sysinfo.json" = { + alias = "/tmp/sysinfo.json"; + extraConfig = '' add_header Content-Type "application/json;charset=UTF-8"; ''; }; }; - "storage.hq.c3d2.ffdd" = { - locations = { - "/".proxyPass = "http://storage.hq.c3d2.de/"; - }; + }; + "storage.hq.c3d2.ffdd" = { + locations = { + "/".proxyPass = "http://storage.hq.c3d2.de/"; }; - "grafana.hq.c3d2.ffdd" = { - locations = { - "/" = { - proxyPass = "https://grafana.hq.c3d2.de/"; - extraConfig = '' + }; + "grafana.hq.c3d2.ffdd" = { + locations = { + "/" = { + proxyPass = "https://grafana.hq.c3d2.de/"; + extraConfig = '' proxy_ssl_server_name on; ''; - }; - }; - }; - "influxdb.hq.c3d2.ffdd" = { - locations = { - "/".proxyPass = "http://grafana.hq.c3d2.de:8086/"; }; }; }; + "influxdb.hq.c3d2.ffdd" = { + locations = { + "/".proxyPass = "http://grafana.hq.c3d2.de:8086/"; + }; + }; + }; }; # This value determines the NixOS release with which your system is to be diff --git a/hosts/containers/freifunk/sysinfo-json.nix b/hosts/containers/freifunk/sysinfo-json.nix new file mode 100644 index 00000000..3aafe3c2 --- /dev/null +++ b/hosts/containers/freifunk/sysinfo-json.nix @@ -0,0 +1,70 @@ +{ pkgs ? import {}, + ffdd-server ? builtins.fetchGit "https://github.com/Freifunk-Dresden/ffdd-server.git", + bmxd, + ddmeshNode, + ... }: + +with pkgs; +let + nvram = { + ddmesh_node = toString ddmeshNode; + city = "Dresden"; + autoupdate = "0"; + contact_name = "C3D2"; + contact_location = "Zentralwerk"; + contact_email = "astro@spaceboyz.net"; + contact_note = "http://www.c3d2.ffdd/"; + gps_latitude = "51.0810624"; + gps_longitude = "13.7285866"; + gps_altitude = "100"; + }; +in +stdenv.mkDerivation { + name = "sysinfo-json"; + src = "${ffdd-server}/salt/freifunk/base/ddmesh/"; + buildPhase = '' + cat > bmxddump.sh < \$DB_PATH/gateways + ${bmxd}/sbin/bmxd -c --links > \$DB_PATH/links + ${bmxd}/sbin/bmxd -c --originators > \$DB_PATH/originators + ${bmxd}/sbin/bmxd -c --status > \$DB_PATH/status + #${bmxd}/sbin/bmxd -c --networks > \$DB_PATH/networks + ${bmxd}/sbin/bmxd -ci > \$DB_PATH/info + EOF + + cat > lsb_release <