Not really related to this solution specifically but:
# wait for tailscaled to settle
sleep 2
This is going to break one day. They're already using systemd units - why not make tailscale notify when it's done with the startup? We have better tools than old initd - let's use them.