-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from JungleCatSoftware/v0.0.4
This release fixes and issue where apt-get upgrade could fail on certain packages (such as grub) that will try and prompt for input and adds in the ability to wait for the AMI to complete and then shutdown.
- Loading branch information
Showing
6 changed files
with
60 additions
and
10 deletions.
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash | ||
echo -e "\n==Waiting for AMI to Finish==" | ||
if [[ "x${dateformat}" != "x" ]]; then | ||
echo -e "Begin at $(date +"${dateformat}")" | ||
fi | ||
|
||
instanceid=$(ec2metadata --instance-id) | ||
availabilityzone=$(ec2metadata --availability-zone) | ||
region=${availabilityzone::-1} | ||
image_id=$(cat $image_id_path | grep ImageId | sed -E 's/.*"ImageId":\s*"(ami-.*)".*/\1/' | head -n1) | ||
image_state="pending" | ||
|
||
while [[ "x$image_state" == "xpending" ]]; do | ||
sleep 30 | ||
echo -e "\tChecking for instance state..." | ||
res=$(aws ec2 describe-images --region "$region" --image-ids "$image_id" --query 'Images[*].{State:State}' 2>/dev/null) | ||
image_state=$(echo $res | grep State | sed -E 's/.*"State":\s*"(pending|available|failed)".*/\1/' | head -n1) | ||
echo -e "\t\tFound state \"$image_state\"" | ||
done | ||
|
||
if [[ "x$image_state" == "xavailable" ]]; then | ||
echo -e "\t[DONE]" | ||
else | ||
echo -e "\t[FAIL]" | ||
fi | ||
|
||
shutdown -h now |
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