Last active
May 4, 2021 14:15
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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