Add 24 files
All checks were successful
Test and Publish Templates / test-and-publish (push) Successful in 14s
All checks were successful
Test and Publish Templates / test-and-publish (push) Successful in 14s
This commit is contained in:
45
tailscale-relay/start.sh
Executable file
45
tailscale-relay/start.sh
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/bin/bash
|
||||
# shellcheck disable=SC1091
|
||||
source "${AGENT_PATH}/common.sh"
|
||||
_check_required_env_vars "CONTAINER_NAME" "RELAY_PORT"
|
||||
|
||||
# Check LXC is available
|
||||
if ! command -v lxc &>/dev/null; then
|
||||
_die "LXC is not installed."
|
||||
fi
|
||||
|
||||
echo "Starting Tailscale Relay container..."
|
||||
|
||||
# Check container exists
|
||||
if ! lxc info "${CONTAINER_NAME}" &>/dev/null; then
|
||||
_die "Container ${CONTAINER_NAME} does not exist. Run install.sh first."
|
||||
fi
|
||||
|
||||
# Start if not already running
|
||||
if lxc info "${CONTAINER_NAME}" 2>/dev/null | grep -q "Status: RUNNING"; then
|
||||
echo "Container is already running."
|
||||
else
|
||||
lxc start "${CONTAINER_NAME}" || _die "Failed to start container"
|
||||
sleep 3
|
||||
fi
|
||||
|
||||
# Wait for tailscaled to be ready
|
||||
echo "Waiting for Tailscale daemon..."
|
||||
for i in $(seq 1 15); do
|
||||
if lxc exec "${CONTAINER_NAME}" -- tailscale status &>/dev/null; then
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
|
||||
# Ensure relay is enabled
|
||||
lxc exec "${CONTAINER_NAME}" -- tailscale set --relay-server-port="${RELAY_PORT}" 2>/dev/null || true
|
||||
|
||||
CONTAINER_IP="${STATIC_IP%%/*}"
|
||||
TAILSCALE_IP=$(lxc exec "${CONTAINER_NAME}" -- tailscale ip -4 2>/dev/null || echo "not yet available")
|
||||
|
||||
echo ""
|
||||
echo "Tailscale Relay started."
|
||||
echo " LAN IP: ${CONTAINER_IP}"
|
||||
echo " Tailscale IP: ${TAILSCALE_IP}"
|
||||
echo " Relay port: ${RELAY_PORT}/udp"
|
||||
Reference in New Issue
Block a user