#!/bin/sh set -e echo "Waiting for DM master to be ready..." sleep 5 # Check if it's TiDB Cloud (requires TLS) if echo "$TEST_DB_HOST" | grep -q "tidbcloud.com"; then echo "Detected TiDB Cloud - downloading CA certificate for TLS..." wget -q -O /tmp/isrgrootx1.pem https://letsencrypt.org/certs/isrgrootx1.pem # Generate source.yaml with TLS for TiDB Cloud cat > /tmp/source.yaml < /tmp/source.yaml < /tmp/task.yaml # Add each table from TABLES variable IFS=',' read -ra TABLE_ARRAY <<< "$TABLES" for table in "${TABLE_ARRAY[@]}"; do table=$(echo "$table" | xargs) # trim whitespace echo " - db-name: \"$DATABASE_NAME\" tbl-name: \"$table\"" >> /tmp/task.yaml done echo "Starting DM sync task..." /dmctl --master-addr=dm-master:8261 start-task /tmp/task.yaml || true echo "Checking task status..." /dmctl --master-addr=dm-master:8261 query-status test-to-local echo "DM initialization complete!"