#!/bin/bash # # Request crawl for a PDS from the Bluesky relay # # Usage: ./request-crawl.sh [relay-url] # Example: ./request-crawl.sh hold01.atcr.io # set -e DEFAULT_RELAY="https://bsky.network/xrpc/com.atproto.sync.requestCrawl" # Parse arguments HOSTNAME="${1:-}" RELAY_URL="${2:-$DEFAULT_RELAY}" # Validate hostname if [ -z "$HOSTNAME" ]; then echo "Error: hostname is required" >&2 echo "" >&2 echo "Usage: $0 [relay-url]" >&2 echo "Example: $0 hold01.atcr.io" >&2 echo "" >&2 echo "Options:" >&2 echo " hostname Hostname of the PDS to request crawl for (required)" >&2 echo " relay-url Relay URL to send crawl request to (default: $DEFAULT_RELAY)" >&2 exit 1 fi # Log what we're doing echo "Requesting crawl for hostname: $HOSTNAME" echo "Sending to relay: $RELAY_URL" # Make the request RESPONSE=$(curl -s -w "\n%{http_code}" -X POST "$RELAY_URL" \ -H "Content-Type: application/json" \ -d "{\"hostname\":\"$HOSTNAME\"}") # Split response and status code HTTP_BODY=$(echo "$RESPONSE" | head -n -1) HTTP_CODE=$(echo "$RESPONSE" | tail -n 1) # Check response if [ "$HTTP_CODE" -ge 200 ] && [ "$HTTP_CODE" -lt 300 ]; then echo "✅ Success! Crawl requested for $HOSTNAME" if [ -n "$HTTP_BODY" ]; then echo "Response: $HTTP_BODY" fi else echo "❌ Failed with status $HTTP_CODE" >&2 if [ -n "$HTTP_BODY" ]; then echo "Response: $HTTP_BODY" >&2 fi exit 1 fi