pihole-ftl: Download macvendor.db in setup service
As done in the update script cef7fd4b02/automated install/basic-install.sh#L1791-L1792
This commit is contained in:
@@ -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})
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user