Files
Your Name 9aa6168f76
All checks were successful
Test and Publish Templates / test-and-publish (push) Successful in 35s
Add tailscale!
2025-09-07 22:52:10 +12:00

45 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
# shellcheck disable=SC1091
source "${AGENT_PATH}/common.sh"
_check_required_env_vars "CONTAINER_NAME" "IMAGE_REGISTRY" "IMAGE_REPO" "IMAGE_TAG" "TAILSCALE_AUTH_KEY"
# Check if auth key is set
if [ -z "$TAILSCALE_AUTH_KEY" ] || [ "$TAILSCALE_AUTH_KEY" = "" ]; then
_die "TAILSCALE_AUTH_KEY is not set in config/service.env! Please add your Tailscale auth key."
fi
_check_docker_installed || _die "Docker test failed, aborting installation..."
echo "Installing Tailscale service..."
echo "Pulling Tailscale image..."
docker pull "$IMAGE_REGISTRY/$IMAGE_REPO:$IMAGE_TAG" || _die "Failed to pull image $IMAGE_REGISTRY/$IMAGE_REPO:$IMAGE_TAG"
# Create volume for persistent state
echo "Creating volume for Tailscale state..."
if ! docker volume create ${STATE_VOLUME}; then
echo "Volume ${STATE_VOLUME} may already exist, continuing..."
fi
# Stop and remove existing container if it exists
if _is_container_exists "$CONTAINER_NAME"; then
echo "Removing existing container..."
bash ./stop.sh 2>/dev/null || true
_remove_container "$CONTAINER_NAME" || true
fi
# Start the tunnel
bash ./start.sh || _die "Failed to start Tailscale"
echo ""
echo "=========================================="
echo "Tailscale installation complete!"
echo "=========================================="
echo ""
echo "Next steps:"
echo "1. Check connection status: ds status [server] tailscale"
echo "2. View logs: ds logs [server] tailscale"
echo "3. Manage device in Tailscale admin console:"
echo " https://login.tailscale.com/admin/machines"
echo ""
echo "Your device should appear as connected in the admin console."