hosts: optionally set CONSUL_HTTP_ADDR from /etc/consul.json

This commit is contained in:
Max Headroom 2024-07-17 22:14:48 +02:00
parent 5616f4887a
commit 825efc9b29

View file

@ -46,6 +46,9 @@ in
ScheduleShutdown st reboot ''${nextScheduledTime}000000
'';
in pkgs.writeShellScript "post-effect.sh" ''
if [[ -e /etc/consul.json ]]; then
export CONSUL_HTTP_ADDR="$(${pkgs.jq}/bin/jq -r < /etc/consul.json '"\(.addresses.http // "127.0.0.1"):\(.ports.http // 8500)"')"
fi
export PATH="${config.packages.consul}/bin:${pkgs.coreutils}/bin"
if [[ "$(realpath /run/booted-system/kernel)" != "$(realpath /nix/var/nix/profiles/system/kernel)" ]]; then
echo "Scheduling reboot for kernel upgrade"