From 41487b640f220120d83bad03cfe6c2d349aefc40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alu=C3=ADsio=20Augusto=20Silva=20Gon=C3=A7alves?= Date: Sat, 21 Nov 2020 16:25:07 -0300 Subject: [PATCH] bird-lg: remove Moved to dn42.nix along with other dn42 services. --- modules/default.nix | 1 - .../networking/monitoring/bird-lg-config.py | 44 ----- .../networking/monitoring/bird-lg.nix | 175 ------------------ patches/bird-lg/default.nix | 17 -- patches/manifest.nix | 1 - patches/overlay.nix | 2 - pkgs/manifest.nix | 1 - pkgs/overlay.nix | 2 - pkgs/servers/monitoring/bird-lg/default.nix | 65 ------- pkgs/servers/monitoring/bird-lg/run-wsgi.sh | 5 - 10 files changed, 313 deletions(-) delete mode 100644 modules/services/networking/monitoring/bird-lg-config.py delete mode 100644 modules/services/networking/monitoring/bird-lg.nix delete mode 100644 patches/bird-lg/default.nix delete mode 100644 pkgs/servers/monitoring/bird-lg/default.nix delete mode 100644 pkgs/servers/monitoring/bird-lg/run-wsgi.sh diff --git a/modules/default.nix b/modules/default.nix index ca50449..4daaf5d 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -1,5 +1,4 @@ { - bird-lg = ./services/networking/monitoring/bird-lg.nix; dma = ./programs/dma.nix; dyndnsc = ./services/networking/dyndnsc.nix; ipfs-cluster = ./services/cluster/ipfs-cluster.nix; diff --git a/modules/services/networking/monitoring/bird-lg-config.py b/modules/services/networking/monitoring/bird-lg-config.py deleted file mode 100644 index 533e970..0000000 --- a/modules/services/networking/monitoring/bird-lg-config.py +++ /dev/null @@ -1,44 +0,0 @@ -# Put everything inside a function to avoid polluting the script's -# global namespace. -def _config_loader_main(): - """ Loads bird-lg and gunicorn config files. """ - import os - - def log_to_syslog(): - """ Configures the logging module to log everything to syslog. """ - from logging.config import dictConfig - import socket - - dictConfig( - { - "version": 1, - "formatters": {"msgonly": {"format": "%(message)s"}}, - "handlers": { - "syslog": { - "class": "logging.handlers.SysLogHandler", - "formatter": "msgonly", - "address": "/dev/log", - "socktype": socket.SOCK_DGRAM, - } - }, - "root": {"handlers": ["syslog"]}, - } - ) - - def load_config_files(): - """ Loads JSON config files specified in the BIRD_LG_CONFIG_FILES environment variable. """ - import json - - for filename in os.environ["BIRD_LG_CONFIG_FILES"].split(os.pathsep): - with open(filename, "r") as file: - config = json.load(file) - globals().update(config) - - if os.environ.get("BIRD_LG_SYSLOG"): - log_to_syslog() - if os.environ.get("BIRD_LG_CONFIG_FILES"): - load_config_files() - - -_config_loader_main() -del _config_loader_main diff --git a/modules/services/networking/monitoring/bird-lg.nix b/modules/services/networking/monitoring/bird-lg.nix deleted file mode 100644 index 994e3a3..0000000 --- a/modules/services/networking/monitoring/bird-lg.nix +++ /dev/null @@ -1,175 +0,0 @@ -{ config, lib, pkgs, ... }: -let - inherit (lib) concatStringsSep mkDefault mkEnableOption mkIf mkOption types; - settingsFormat = pkgs.formats.json { }; - - cfg = config.services.bird-lg; -in -{ - - options = { - services.bird-lg.server = { - enable = mkEnableOption "BIRD looking glass server"; - - logToSyslog = mkOption { - description = "Whether to log to journald via syslog instead of writing to stderr."; - type = types.bool; - default = true; - }; - - appSettings = mkOption { - description = "Configuration for bird-lg's server."; - type = settingsFormat.type; - default = { }; - }; - - gunicornSettings = mkOption { - description = "Configuration for the Gunicorn instance running bird-lg's server."; - type = settingsFormat.type; - default = { }; - }; - - extraConfigFiles = mkOption { - description = "Extra JSON files containing configuration, for example secrets."; - type = types.listOf types.path; - default = [ ]; - }; - }; - - services.bird-lg.client = { - enable = mkEnableOption "BIRD looking glass client proxy"; - - logToSyslog = mkOption { - description = "Whether to log to journald via syslog instead of writing to stderr."; - type = types.bool; - default = true; - }; - - appSettings = mkOption { - description = "Configuration for bird-lg's client proxy."; - type = settingsFormat.type; - default = { }; - }; - - gunicornSettings = mkOption { - description = "Configuration for the Gunicorn instance running bird-lg's client proxy."; - type = settingsFormat.type; - default = { }; - }; - - extraConfigFiles = mkOption { - description = "Extra JSON files containing configuration, for example secrets."; - type = types.listOf types.path; - default = [ ]; - }; - }; - }; - - config = { - - ################ - # Server setup # - ################ - - services.bird-lg.server.appSettings = { - DEBUG = mkDefault true; - LOG_LEVEL = mkDefault "WARNING"; - PROXY = mkDefault { }; - PROXY_TIMEOUT = mkDefault { - bird = 10; - traceroute = 60; - }; - UNIFIED_DAEMON = mkDefault true; - }; - - services.bird-lg.server.gunicornSettings = mkIf cfg.server.logToSyslog { - errorlog = mkDefault "/dev/null"; - syslog = mkDefault true; - syslog_addr = mkDefault "unix:///dev/log"; - }; - - systemd.services.bird-lg-server = mkIf cfg.server.enable { - description = "BIRD looking glass web server"; - requires = [ "network-online.target" ]; - after = [ "bird.service" "bird6.service" "bird2.service" "network-online.target" ]; - wantedBy = [ "multi-user.target" ]; - environment = { - BIRD_LG_CONFIG = ./bird-lg-config.py; - BIRD_LG_CONFIG_FILES = concatStringsSep ":" ([ - (settingsFormat.generate "bird-lg-gunicorn.json" cfg.server.gunicornSettings) - (settingsFormat.generate "bird-lg.json" cfg.server.appSettings) - ] ++ cfg.server.extraConfigFiles); - BIRD_LG_SYSLOG = toString cfg.server.logToSyslog; - }; - serviceConfig = { - Type = "simple"; - ExecStart = "${pkgs.bird-lg}/bin/bird-lg-webservice --config=\${BIRD_LG_CONFIG}"; - Restart = "on-failure"; - - DynamicUser = true; - NoNewPrivileges = true; - ProtectSystem = "strict"; - ProtectHome = true; - ProtectKernelLogs = true; - ProtectKernelModules = true; - ProtectKernelTunables = true; - ProtectControlGroups = true; - PrivateDevices = true; - PrivateTmp = true; - DevicePolicy = "closed"; - MemoryDenyWriteExecute = true; - }; - }; - - ###################### - # Client proxy setup # - ###################### - - services.bird-lg.client.appSettings = { - DEBUG = mkDefault false; - LOG_LEVEL = mkDefault "WARNING"; - BIRD_SOCKET = mkDefault "/run/bird.ctl"; - BIRD6_SOCKET = mkDefault "/run/bird6.ctl"; - }; - - services.bird-lg.client.gunicornSettings = mkIf cfg.client.logToSyslog { - errorlog = mkDefault "/dev/null"; - syslog = mkDefault true; - syslog_addr = mkDefault "unix:///dev/log#dgram"; - }; - - systemd.services.bird-lg-client = mkIf cfg.client.enable { - description = "BIRD looking glass client proxy"; - requires = [ "network-online.target" ]; - after = [ "bird.service" "bird6.service" "bird2.service" "network-online.target" ]; - wantedBy = [ "multi-user.target" ]; - environment = { - BIRD_LG_CONFIG = ./bird-lg-config.py; - BIRD_LG_CONFIG_FILES = concatStringsSep ":" ([ - (settingsFormat.generate "bird-lgproxy-gunicorn.json" cfg.client.gunicornSettings) - (settingsFormat.generate "bird-lgproxy.json" cfg.client.appSettings) - ] ++ cfg.client.extraConfigFiles); - BIRD_LG_SYSLOG = toString cfg.client.logToSyslog; - }; - serviceConfig = { - Type = "simple"; - ExecStart = "${pkgs.bird-lg}/bin/bird-lg-proxy --config=\${BIRD_LG_CONFIG}"; - Restart = "on-failure"; - - DynamicUser = true; - NoNewPrivileges = true; - ProtectSystem = "strict"; - ProtectHome = true; - ProtectKernelLogs = true; - ProtectKernelModules = true; - ProtectKernelTunables = true; - ProtectControlGroups = true; - PrivateDevices = true; - PrivateTmp = true; - DevicePolicy = "closed"; - }; - }; - - }; - -} diff --git a/patches/bird-lg/default.nix b/patches/bird-lg/default.nix deleted file mode 100644 index 7b9aa3a..0000000 --- a/patches/bird-lg/default.nix +++ /dev/null @@ -1,17 +0,0 @@ -{ fetchpatch, bird-lg }: - -bird-lg.overrideAttrs (oldAttrs: { - patches = (oldAttrs.patches or [ ]) ++ [ - (fetchpatch { - name = "bird-lg_dont_configure_log_file.patch"; - url = "https://github.com/AluisioASG/bird-lg/commit/e58112848e7160fb3cb71b5ca674ac3537e12b05.patch"; - sha256 = "0daqkql0a8slqap8pybngm4al96pcki69vai0807vck4gi4paw0z"; - }) - ]; - - postPatch = '' - # Replace the builtin config file with one given through an - # environment variable. - sed -i '/app\.config\.from_pyfile/c app.config.from_envvar("BIRD_LG_CONFIG")' lg.py lgproxy.py - ''; -}) diff --git a/patches/manifest.nix b/patches/manifest.nix index 6ad0771..88d8218 100644 --- a/patches/manifest.nix +++ b/patches/manifest.nix @@ -1,5 +1,4 @@ [ - [ "bird-lg" ] [ "haunt" ] [ "ipfs-cluster" ] ] diff --git a/patches/overlay.nix b/patches/overlay.nix index 5e79f66..fdadd23 100644 --- a/patches/overlay.nix +++ b/patches/overlay.nix @@ -2,8 +2,6 @@ final: prev: { - bird-lg = final.callPackage ./bird-lg { inherit (prev) bird-lg; }; - haunt = final.callPackage ./haunt { inherit (prev) haunt; }; ipfs-cluster = final.callPackage ./ipfs-cluster { inherit (prev) ipfs-cluster; }; diff --git a/pkgs/manifest.nix b/pkgs/manifest.nix index f1ad184..0160185 100644 --- a/pkgs/manifest.nix +++ b/pkgs/manifest.nix @@ -1,5 +1,4 @@ [ - [ "bird-lg" ] [ "dma" ] [ "drep" ] [ "dyndnsc" ] diff --git a/pkgs/overlay.nix b/pkgs/overlay.nix index aee527f..8a50f97 100644 --- a/pkgs/overlay.nix +++ b/pkgs/overlay.nix @@ -2,8 +2,6 @@ final: prev: { - bird-lg = final.callPackage ./servers/monitoring/bird-lg { }; - dma = final.callPackage ./tools/networking/dma { }; drep = final.callPackage ./tools/text/drep { diff --git a/pkgs/servers/monitoring/bird-lg/default.nix b/pkgs/servers/monitoring/bird-lg/default.nix deleted file mode 100644 index c4d91c2..0000000 --- a/pkgs/servers/monitoring/bird-lg/default.nix +++ /dev/null @@ -1,65 +0,0 @@ -{ stdenv, fetchFromGitHub, fetchpatch, graphviz, python3, traceroute, whois }: -let - runtimeDeps = [ - (python3.withPackages (ps: with ps; [ - flask - dnspython - gunicorn - pydot - memcached - ])) - graphviz - whois - traceroute - ]; -in -stdenv.mkDerivation rec { - pname = "bird-lg-burble"; - version = "2020-05-20-unstable"; - - src = fetchFromGitHub { - owner = "sesa-me"; - repo = "bird-lg"; - rev = "f3699a3b61f2d9f77cb17fb163bcf3c3ad722835"; # refs/head/burble-clean - sha256 = "0gisi6mbfclw36kms3qy3b0wzcwdkd50p2a6xdwggln4fi5y6bh1"; - }; - - patches = [ - (fetchpatch { - name = "fix-bgpmap-generation.patch"; - url = "https://github.com/sesa-me/bird-lg/commit/db8fb829d51889fab61bfb5ffac89199442d3117.patch"; - sha256 = "1vwr7ck5v7w4fr78kbc4wxyj3licsw7h0772xkmmxsb8vp9vcihg"; - }) - ]; - - WRAPPER_PATH = stdenv.lib.makeBinPath runtimeDeps; - WRAPPER_PYTHONPATH = placeholder "out"; - - installPhase = '' - function wrapWSGI { - set -e - substitute ${./run-wsgi.sh} "$2" \ - --subst-var shell \ - --subst-var WRAPPER_PATH \ - --subst-var WRAPPER_PYTHONPATH \ - --subst-var-by SCRIPT "$1" - chmod +x "$2" - } - - runHook preInstall - mkdir -p $out $out/bin - cp -r * $out - touch $out/__init__.py - wrapWSGI lg:app $out/bin/bird-lg-webservice - wrapWSGI lgproxy:app $out/bin/bird-lg-proxy - runHook postInstall - ''; - - meta = with stdenv.lib; { - description = "Looking glass for the BIRD Internet Routing Daemon"; - homepage = "https://github.com/sesa-me/bird-lg"; - license = licenses.gpl3Only; - platforms = platforms.unix; - maintainers = with maintainers; [ AluisioASG ]; - }; -} diff --git a/pkgs/servers/monitoring/bird-lg/run-wsgi.sh b/pkgs/servers/monitoring/bird-lg/run-wsgi.sh deleted file mode 100644 index 9985268..0000000 --- a/pkgs/servers/monitoring/bird-lg/run-wsgi.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!@shell@ -PATH=@WRAPPER_PATH@ -PYTHONPATH=@WRAPPER_PYTHONPATH@ -export PATH PYTHONPATH -exec python -m gunicorn.app.wsgiapp @SCRIPT@ "$@" -- 2.26.2