Unverified Commit 830c3bf6 authored by Sandro Jäckel's avatar Sandro Jäckel Committed by GitHub
Browse files

pihole-ftl: Fix files.macvendor setting, and download database (fixes #428282) (#428690)

parents e2ec455a 8b2f0577
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@ let
      comment = list.description;
    };
  payloads = map makePayload cfg.lists;
  macvendorURL = lib.strings.escapeShellArg cfg.macvendorURL;
in
''
  # Can't use -u (unset) because api.sh uses API_URL before it is set
@@ -22,8 +23,10 @@ in
  pihole="${lib.getExe pihole}"
  jq="${lib.getExe pkgs.jq}"

  ${lib.getExe pkgs.curl} --retry 3 --retry-delay 5 "${macvendorURL}" -o "${cfg.settings.files.macvendor}" || echo "Failed to download MAC database from ${macvendorURL}"

  # If the database doesn't exist, it needs to be created with gravity.sh
  if [ ! -f '${cfg.stateDirectory}'/gravity.db ]; then
  if [ ! -f '${cfg.settings.files.gravity}' ]; then
    $pihole -g
    # Send SIGRTMIN to FTL, which makes it reload the database, opening the newly created one
    ${lib.getExe' pkgs.procps "kill"} -s SIGRTMIN $(systemctl show --property MainPID --value ${config.systemd.services.pihole-ftl.name})
+9 −1
Original line number Diff line number Diff line
@@ -118,6 +118,14 @@ in
      '';
    };

    macvendorURL = mkOption {
      type = types.str;
      default = "https://ftl.pi-hole.net/macvendor.db";
      description = ''
        URL from which to download the macvendor.db file.
      '';
    };

    pihole = mkOption {
      type = types.package;
      default = piholeScript;
@@ -260,7 +268,7 @@ in
        files = {
          database = "${cfg.stateDirectory}/pihole-FTL.db";
          gravity = "${cfg.stateDirectory}/gravity.db";
          macvendor = "${cfg.stateDirectory}/gravity.db";
          macvendor = "${cfg.stateDirectory}/macvendor.db";
          log.ftl = "${cfg.logDirectory}/FTL.log";
          log.dnsmasq = "${cfg.logDirectory}/pihole.log";
          log.webserver = "${cfg.logDirectory}/webserver.log";
+2 −1
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  nixosTests,
  fetchFromGitHub,
  cmake,
  gmp,
@@ -12,7 +13,6 @@
  readline,
  xxd,
  iproute2,
  ...
}:

stdenv.mkDerivation (finalAttrs: {
@@ -78,6 +78,7 @@ stdenv.mkDerivation (finalAttrs: {
  '';

  passthru.settingsTemplate = ./pihole.toml;
  passthru.tests = nixosTests.pihole-ftl;

  meta = {
    description = "Pi-hole FTL engine";
+3 −0
Original line number Diff line number Diff line
{
  stdenv,
  lib,
  nixosTests,
  fetchFromGitHub,
  pihole,
  pihole-ftl,
@@ -36,6 +37,8 @@ stdenv.mkDerivation (finalAttrs: {
    runHook postInstall
  '';

  passthru.tests = nixosTests.pihole-ftl;

  meta = {
    description = "Pi-hole web dashboard displaying stats and more";
    homepage = "https://github.com/pi-hole/web";
+3 −0
Original line number Diff line number Diff line
{
  lib,
  nixosTests,
  fetchFromGitHub,
  makeBinaryWrapper,
  installShellFiles,
@@ -238,6 +239,8 @@
    mainProgram = "pihole";
  };

  passthru.tests = nixosTests.pihole-ftl;

  passthru = {
    inherit stateDir;
  };