pihole-ftl: Download macvendor.db in setup service

As done in the update script https://github.com/pi-hole/pi-hole/blob/cef7fd4b02c9ae4314e7478c0d542379bfce7f65/automated install/basic-install.sh#L1791-L1792

averyv 155cdfb0 113e3681

+12 -1
+4 -1
nixos/modules/services/networking/pihole-ftl-setup-script.nix
··· 15 15 comment = list.description; 16 16 }; 17 17 payloads = map makePayload cfg.lists; 18 + macvendorURL = lib.strings.escapeShellArg cfg.macvendorURL; 18 19 in 19 20 '' 20 21 # Can't use -u (unset) because api.sh uses API_URL before it is set ··· 22 23 pihole="${lib.getExe pihole}" 23 24 jq="${lib.getExe pkgs.jq}" 24 25 26 + ${lib.getExe pkgs.curl} --retry 3 --retry-delay 5 "${macvendorURL}" -o "${cfg.settings.files.macvendor}" || echo "Failed to download MAC database from ${macvendorURL}" 27 + 25 28 # If the database doesn't exist, it needs to be created with gravity.sh 26 - if [ ! -f '${cfg.stateDirectory}'/gravity.db ]; then 29 + if [ ! -f '${cfg.settings.files.gravity}' ]; then 27 30 $pihole -g 28 31 # Send SIGRTMIN to FTL, which makes it reload the database, opening the newly created one 29 32 ${lib.getExe' pkgs.procps "kill"} -s SIGRTMIN $(systemctl show --property MainPID --value ${config.systemd.services.pihole-ftl.name})
+8
nixos/modules/services/networking/pihole-ftl.nix
··· 118 118 ''; 119 119 }; 120 120 121 + macvendorURL = mkOption { 122 + type = types.str; 123 + default = "https://ftl.pi-hole.net/macvendor.db"; 124 + description = '' 125 + URL from which to download the macvendor.db file. 126 + ''; 127 + }; 128 + 121 129 pihole = mkOption { 122 130 type = types.package; 123 131 default = piholeScript;