about summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorAaron Andersen <aaron@fosslib.net>2024-01-28 06:24:11 -0800
committerGitHub <noreply@github.com>2024-01-28 06:24:11 -0800
commit0ed21f3b09508075bac2014c3baaa2ee7c9a851a (patch)
tree9ee4b41d3bee02726af70398a29e8a6add28fd17 /nixos
parent4feedd7957670dbac653fe312b3d765663d747e9 (diff)
parentbdce5312c9458eff44132647867dd55397ba09b1 (diff)
Merge pull request #284122 from Stunkymonkey/zabbix-write-secret
nixos/{zabbixServer,zabbixProxy}: prefer 'install' over 'mkdir/chmod/chown'
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/services/monitoring/zabbix-proxy.nix5
-rw-r--r--nixos/modules/services/monitoring/zabbix-server.nix5
2 files changed, 2 insertions, 8 deletions
diff --git a/nixos/modules/services/monitoring/zabbix-proxy.nix b/nixos/modules/services/monitoring/zabbix-proxy.nix
index 503e81b48a587..fea5704af6f66 100644
--- a/nixos/modules/services/monitoring/zabbix-proxy.nix
+++ b/nixos/modules/services/monitoring/zabbix-proxy.nix
@@ -299,10 +299,7 @@ in
         fi
       '' + optionalString (cfg.database.passwordFile != null) ''
         # create a copy of the supplied password file in a format zabbix can consume
-        touch ${passwordFile}
-        chmod 0600 ${passwordFile}
-        echo -n "DBPassword = " > ${passwordFile}
-        cat ${cfg.database.passwordFile} >> ${passwordFile}
+        install -m 0600 <(echo "DBPassword = $(cat ${cfg.database.passwordFile})") ${passwordFile}
       '';
 
       serviceConfig = {
diff --git a/nixos/modules/services/monitoring/zabbix-server.nix b/nixos/modules/services/monitoring/zabbix-server.nix
index 0607188d21319..f2fb5fbe7ac66 100644
--- a/nixos/modules/services/monitoring/zabbix-server.nix
+++ b/nixos/modules/services/monitoring/zabbix-server.nix
@@ -292,10 +292,7 @@ in
         fi
       '' + optionalString (cfg.database.passwordFile != null) ''
         # create a copy of the supplied password file in a format zabbix can consume
-        touch ${passwordFile}
-        chmod 0600 ${passwordFile}
-        echo -n "DBPassword = " > ${passwordFile}
-        cat ${cfg.database.passwordFile} >> ${passwordFile}
+        install -m 0600 <(echo "DBPassword = $(cat ${cfg.database.passwordFile})") ${passwordFile}
       '';
 
       serviceConfig = {