31 lines
1.1 KiB
Bash
Executable file
31 lines
1.1 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
source .env
|
|
|
|
for i in {1..10}; do
|
|
# Check if the instance is running
|
|
INSTANCE_STATUS=$(gcloud compute instances describe k3s-vm-1 --zone=us-central1-a --project="$PROJECT_NAME" --format='get(status)')
|
|
if [[ "$INSTANCE_STATUS" != "RUNNING" ]]; then
|
|
echo "Instance k3s-vm-1 is not running. Attempt $i/10. Waiting 5 seconds..."
|
|
sleep 5
|
|
continue
|
|
fi
|
|
|
|
# Check if the directory exists on the remote host
|
|
if gcloud compute ssh k3s-vm-1 --zone=us-central1-a --project="$PROJECT_NAME" --command="test -d /opt/src/infctl-cli/"; then
|
|
echo "/opt/src/infctl-cli/ exists on k3s-vm-1."
|
|
break
|
|
else
|
|
echo "/opt/src/infctl-cli/ does not exist yet. Attempt $i/10. Waiting 5 seconds..."
|
|
sleep 5
|
|
fi
|
|
done
|
|
|
|
# Final check after loop
|
|
if ! gcloud compute ssh k3s-vm-1 --zone=us-central1-a --project="$PROJECT_NAME" --command="test -d /opt/src/infctl-cli/"; then
|
|
echo "ERROR: /opt/src/infctl-cli/ does not exist on k3s-vm-1 after 10 attempts. Exiting."
|
|
exit 1
|
|
fi
|
|
|
|
gcloud compute scp .env k3s-vm-1:/opt/src/infctl-cli/.env --zone=us-central1-a --project=$PROJECT_NAME
|
|
|