Skip to content

Instantly share code, notes, and snippets.

@Enigo
Last active September 16, 2023 11:10
Show Gist options
  • Save Enigo/b4e94deb4895b512a1ab3d843eff59c2 to your computer and use it in GitHub Desktop.
Save Enigo/b4e94deb4895b512a1ab3d843eff59c2 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
region=$(curl http://169.254.169.254/latest/meta-data/placement/region | sed 's/-1$//')
sed -i "s/<DATACENTER>/${region}/g" /opt/scylla_setup/setup.cql
ip=$(curl http://169.254.169.254/latest/meta-data/local-ipv4)
export CQLSH_HOST=$ip
max_attempts=30
retry_interval=10
echo "Waiting for $ip to become available..."
for (( i=0; i<max_attempts; i++ )); do
if cqlsh -e 'describe cluster'; then
echo "ScyllaDB is up! Executing initial DB configuration"
cqlsh -f /opt/scylla_setup/setup.cql
exit 0
else
echo "Attempt $i: ScyllaDB is not yet available. Retrying in $retry_interval seconds..."
sleep $retry_interval
fi
done
echo "ScyllaDB did not become available after $max_attempts attempts."
exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment