influxdb: Use a flag file for the first init
This commit is contained in:
parent
c8467650a0
commit
4b555b87ab
|
@ -44,10 +44,12 @@
|
||||||
IPAddressAllow = "localhost";
|
IPAddressAllow = "localhost";
|
||||||
UMask = "077";
|
UMask = "077";
|
||||||
RuntimeDirectory = "influxdb";
|
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" ''
|
ExecStartPost = lib.mkForce [ (pkgs.writeShellScript "influxdb-first-run" ''
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
if [ ! -s /var/lib/influxdb/admin.pw ]; then
|
if [ ! -s /var/lib/influxdb/admin.pw ]; then
|
||||||
INIT=1
|
|
||||||
( tr -dc _A-Z-a-z-0-9 </dev/urandom || : ) | head -c32 > /var/lib/influxdb/admin.pw
|
( tr -dc _A-Z-a-z-0-9 </dev/urandom || : ) | head -c32 > /var/lib/influxdb/admin.pw
|
||||||
chmod 400 /var/lib/influxdb/admin.pw
|
chmod 400 /var/lib/influxdb/admin.pw
|
||||||
fi
|
fi
|
||||||
|
@ -62,7 +64,8 @@
|
||||||
until ${pkgs.curl}/bin/curl --connect-timeout 1 http://127.0.0.1:8086/ping; do
|
until ${pkgs.curl}/bin/curl --connect-timeout 1 http://127.0.0.1:8086/ping; do
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
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 adminpw < /var/lib/influxdb/admin.pw
|
||||||
read -N 32 -r knotendatenpw < /var/lib/influxdb/knotendaten.pw
|
read -N 32 -r knotendatenpw < /var/lib/influxdb/knotendaten.pw
|
||||||
read -N 32 -r grafanapw < /var/lib/influxdb/grafana.pw
|
read -N 32 -r grafanapw < /var/lib/influxdb/grafana.pw
|
||||||
|
|
Loading…
Reference in a new issue