Skip to content

Instantly share code, notes, and snippets.

@TiagoGouvea
Created May 1, 2020 19:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TiagoGouvea/719b230febb74bfe77f11856a7ff300d to your computer and use it in GitHub Desktop.
Save TiagoGouvea/719b230febb74bfe77f11856a7ff300d to your computer and use it in GitHub Desktop.
Script to setup a send a file to a instance on Google Cloud Platform and run it
#!/usr/bin/env bash
echo -e "\nSetup remote instance"
echo -e "\n# 1/3 - Loading and setting options..."
## Show commands (if you want to check, uncomment it)
#set -x
## Stop on errors
set -e
## Include config
source config.sh
## Set GCP compute zone
gcloud config set project ${PROJECT}
gcloud config set compute/zone ${ZONE}
## Copy script
echo -e "\n# 2/2 - Copying required files..."
gcloud compute scp ./local-setup.sh ${INSTANCE_NAME}:~
gcloud compute scp ./config.sh ${INSTANCE_NAME}:~
## Create remote path
echo -e "\n# 3/3 - Staring remote setup..."
gcloud beta compute --project ${PROJECT} ssh ${INSTANCE_NAME} --zone ${ZONE} --command="chmod +x local-setup.sh && ./local-setup.sh"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment