mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-10-04 11:37:19 +03:00
nixos/geoipupdate: Create database directory in a separate unit
The database directory needs to be created before the geoipupdate.service unit is activated; otherwise, systemd will not be able to set up the mount namespacing to grant the service read-write access.
This commit is contained in:
parent
7cf55d1f4e
commit
ba4d2bd03c
@ -99,9 +99,22 @@ in
|
|||||||
LockFile = "/run/geoipupdate/.lock";
|
LockFile = "/run/geoipupdate/.lock";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
systemd.services.geoipupdate-create-db-dir = {
|
||||||
|
serviceConfig.Type = "oneshot";
|
||||||
|
script = ''
|
||||||
|
mkdir -p ${cfg.settings.DatabaseDirectory}
|
||||||
|
chmod 0755 ${cfg.settings.DatabaseDirectory}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
systemd.services.geoipupdate = {
|
systemd.services.geoipupdate = {
|
||||||
description = "GeoIP Updater";
|
description = "GeoIP Updater";
|
||||||
after = [ "network-online.target" "nss-lookup.target" ];
|
requires = [ "geoipupdate-create-db-dir.service" ];
|
||||||
|
after = [
|
||||||
|
"geoipupdate-create-db-dir.service"
|
||||||
|
"network-online.target"
|
||||||
|
"nss-lookup.target"
|
||||||
|
];
|
||||||
wants = [ "network-online.target" ];
|
wants = [ "network-online.target" ];
|
||||||
startAt = cfg.interval;
|
startAt = cfg.interval;
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
@ -122,8 +135,6 @@ in
|
|||||||
geoipupdateConf = pkgs.writeText "geoipupdate.conf" (geoipupdateKeyValue cfg.settings);
|
geoipupdateConf = pkgs.writeText "geoipupdate.conf" (geoipupdateKeyValue cfg.settings);
|
||||||
|
|
||||||
script = ''
|
script = ''
|
||||||
mkdir -p "${cfg.settings.DatabaseDirectory}"
|
|
||||||
chmod 755 "${cfg.settings.DatabaseDirectory}"
|
|
||||||
chown geoip "${cfg.settings.DatabaseDirectory}"
|
chown geoip "${cfg.settings.DatabaseDirectory}"
|
||||||
|
|
||||||
cp ${geoipupdateConf} /run/geoipupdate/GeoIP.conf
|
cp ${geoipupdateConf} /run/geoipupdate/GeoIP.conf
|
||||||
|
Loading…
Reference in New Issue
Block a user