Created
February 14, 2017 01:00
-
-
Save euank/e3a8f59d70933cfec124f1f8477bfc20 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
while true; do | |
instance_id=$(aws ec2 run-instances --key-name euank --instance-type m1.small --region=us-east-1 --image-id ami-8b7b759c | jq '.Instances[].InstanceId' -r) | |
sleep 20 | |
while true; do | |
console=$(aws ec2 --region=us-east-1 get-console-output --instance-id $instance_id | jq '.Output' -r) | |
if [[ "$console" == "null" ]]; then | |
sleep 30 | |
continue | |
fi | |
if grep "Reached target Multi-User System." <(echo $console); then | |
# Success! | |
echo "Success for $instance_id" | |
aws ec2 terminate-instances --region=us-east-1 --instance-ids $instance_id | |
break | |
fi | |
if grep "page_fault" <(echo $console); then | |
echo "Failure! for $instance_id" | |
echo $console | |
exit 1 | |
fi | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment