Server/tailscale: wait to get ip address

This commit is contained in:
Toast 2024-08-16 19:57:08 +02:00
parent 16fa01ad7d
commit 2c45da4844

View file

@ -1,6 +1,21 @@
{...}: {
{pkgs, ...}: let
script = pkgs.writeShellApplication {
name = "tailscale-wait-for-ip";
runtimeInputs = [pkgs.iproute2];
text = ''
# Based on https://github.com/tailscale/tailscale/issues/11504#issuecomment-2113331262
echo Waiting for tailscale0 to get an IP adress..
for i in {1..15}; do
if ip addr show dev tailscale0 | grep -q 'inet '; then break; fi
echo "$i"
sleep 1
done
'';
};
in {
services.tailscale = {
# This is needed for being an exit node
useRoutingFeatures = "server";
};
systemd.services.tailscaled.postStart = "${script}/bin/tailscale-wait-for-ip";
}