From 4b555b87abd149c3876f187e67a2757e7c14d383 Mon Sep 17 00:00:00 2001 From: Daniel Frank Date: Tue, 25 Jan 2022 20:58:35 +0100 Subject: [PATCH] influxdb: Use a flag file for the first init --- influxdb.nix | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/influxdb.nix b/influxdb.nix index dab8b80..9d89a32 100644 --- a/influxdb.nix +++ b/influxdb.nix @@ -44,10 +44,12 @@ IPAddressAllow = "localhost"; UMask = "077"; RuntimeDirectory = "influxdb"; + ExecStartPre = [ (pkgs.writeShellScript "influxdb-first-run" '' + [ -d /var/lib/influxdb/meta ] || touch /var/lib/influxdb/need-init + '') ]; ExecStartPost = lib.mkForce [ (pkgs.writeShellScript "influxdb-first-run" '' set -euo pipefail if [ ! -s /var/lib/influxdb/admin.pw ]; then - INIT=1 ( tr -dc _A-Z-a-z-0-9 /var/lib/influxdb/admin.pw chmod 400 /var/lib/influxdb/admin.pw fi @@ -62,7 +64,8 @@ until ${pkgs.curl}/bin/curl --connect-timeout 1 http://127.0.0.1:8086/ping; do sleep 1 done - if [ -v INIT ]; then + if [ -e /var/lib/influxdb/need-init ]; then + rm -f /var/lib/influxdb/need-init read -N 32 -r adminpw < /var/lib/influxdb/admin.pw read -N 32 -r knotendatenpw < /var/lib/influxdb/knotendaten.pw read -N 32 -r grafanapw < /var/lib/influxdb/grafana.pw