Skip to content

Instantly share code, notes, and snippets.

@frederikstroem
Created January 16, 2024 22:59
Show Gist options
  • Save frederikstroem/d72532b46ed1187aa750aedfd51af57f to your computer and use it in GitHub Desktop.
Save frederikstroem/d72532b46ed1187aa750aedfd51af57f to your computer and use it in GitHub Desktop.
Wait for Tailscale/Headscale backend to start before starting Systemd user service
[Unit]
Description=Waiting for Tailscale Backend
[Service]
Type=simple
EnvironmentFile=%h/waiting_service/.env
ExecStartPre=/usr/bin/bash -c 'until [[ "$(tailscale status --json | jq -r '.BackendState')" == "Running" ]]; do sleep 1; done' # Wait for Tailscale/Headscale to start.
ExecStart=/usr/bin/python3 %h/waiting_service/main.py
Restart=always
RestartSec=5
[Install]
WantedBy=default.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment