Skip to content

Instantly share code, notes, and snippets.

@agmm
Created March 15, 2020 16:29
Show Gist options
  • Save agmm/56bf1ea3a4cace6f3bcdb213f2faa483 to your computer and use it in GitHub Desktop.
Save agmm/56bf1ea3a4cace6f3bcdb213f2faa483 to your computer and use it in GitHub Desktop.
machine="machine-name"
echo "Starting gcloud VM"
OUTPUT="$(gcloud compute instances start "${machine}" --format="json")"
ip="$(echo "$OUTPUT" | grep natIP | grep -E -o "([0-9]{1,3}[\.]){3}[0-9]{1,3}")"
echo "----------"
echo "VM Name: ${machine}"
echo "VM External IP: ${ip}"
echo "----------"
echo "Waiting 30 seconds before starting server"
sleep 30
echo "Creating sshcode server on the remote machine"
./sshcode user@"${ip}"
echo "Stopping gcloud VM"
gcloud compute instances stop "${machine}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment