#!/bin/sh set -e echo "[+] Waiting for headscale-client to be resolvable..." # Loop until headscale-client IP is found or timeout timeout=30 start_time=$(date +%s) HEADSCALE_IP="" while [ -z "$HEADSCALE_IP" ]; do HEADSCALE_IP=$(getent hosts headscale-client | awk '{ print $1 }' | head -n 1) current_time=$(date +%s) if [ $((current_time - start_time)) -ge $timeout ]; then echo "[-] Timeout waiting for headscale-client DNS resolution." >&2 exit 1 fi if [ -z "$HEADSCALE_IP" ]; then sleep 1 fi done echo "[+] Found headscale-client IP: $HEADSCALE_IP" echo "[+] Attempting to modify routing table..." apt update && apt install -y iproute2 ip route del default || echo "[-] Warning: Failed to delete default route (maybe none existed)." ip route add default via $HEADSCALE_IP echo "[+] Default route set via $HEADSCALE_IP." echo "[+] Starting Nginx..." nginx -g "daemon off;"