Skip to content

Instantly share code, notes, and snippets.

@minherz
Last active May 4, 2021 14:15
Show Gist options
  • Save minherz/a9f7574aa1888117c5c3cc98dd906142 to your computer and use it in GitHub Desktop.
Save minherz/a9f7574aa1888117c5c3cc98dd906142 to your computer and use it in GitHub Desktop.
Bash script function to wait until the startup script finishes execution and logs it into /var/log/syslog
wait_startup_script_to_finish() {
vm_name=$1
vm_zone=$2
echo -n "Wait for \"$vm_name\" startup script to exit."
status=""
while [[ -z "$status" ]]
do
sleep 3;
echo -n "."
status=$(gcloud compute ssh $vm_name --zone=$vm_zone --ssh-flag="-q" --command 'grep -m 1 "startup-script exit status" /var/log/syslog' 2>&-)
done
echo ""
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment