Walter Stanish avatar Walter Stanish committed 2eff28f

Backtick error handling.

Comments (0)

Files changed (1)

     report_status "set up group"
     group="gentoo-bootstrap"
 
-    group_exists=`ec2-describe-group \
+    group_exists="`ec2-describe-group \
             --region $region \
             --filter group-name=$group \
-            | wc -c`
+            | wc -c`"
 
     if [ $group_exists -eq 0 ]; then
         ec2-create-group --region $region $group --description "Gentoo Bootstrap"
 
 report_status "finding latest kernel-id"
 
-latest_kernel=`ec2-describe-images \
+latest_kernel="`ec2-describe-images \
 --region $region \
 --filter image-type=kernel \
 --filter manifest-location=*pv-grub* \
 --owner amazon \
 --filter architecture=${architecture} \
-| grep -v "hd00" \
-| awk '{ print $3 "\t"  $2 }' \
-| sed "s:.*/pv-grub-hd0[^0-9]*::" \
+| grep -v 'hd00' \
+| awk '{ print $3 \"\t\"  $2 }' \
+| sed 's:.*/pv-grub-hd0[^0-9]*::' \
 | sort \
 | tail -n 1 \
-| awk '{ print $2 }'`
+| awk '{ print $2 }'`"
 
 report_status "kernel-id = $latest_kernel"
 
 report_status "finding bootstrap image"
 
-boot_image=`ec2-describe-images \
+boot_image="`ec2-describe-images \
 --region $region \
 --owner amazon \
 --filter architecture=${architecture} \
 --filter virtualization-type=paravirtual \
 --filter kernel-id=${latest_kernel} \
 --filter manifest-location=amazon/amzn-ami-pv-* \
-| grep "^IMAGE" \
-| grep -v "amazon/amzn-ami-pv-*.*.rc-*" \
+| grep '^IMAGE' \
+| grep -v 'amazon/amzn-ami-pv-*.*.rc-*' \
 | tail -n 1 \
-| awk '{ print $2 }'`
+| awk '{ print $2 }'`"
 
 report_status "bootstrap image = $boot_image"
 
 report_status "starting bootstrap instance"
 
-instance=`ec2-run-instances \
+instance="`ec2-run-instances \
 --region $region \
 $boot_image \
 --group $group \
 --key $key \
 --instance-type $instance_type \
---block-device-mapping "/dev/sdf=:10" \
-| grep "^INSTANCE" \
-| awk '{ print $2 }'`
+--block-device-mapping '/dev/sdf=:10' \
+| grep '^INSTANCE' \
+| awk '{ print $2 }'`"
 
 report_status "bootstrap instance = $instance"
 
 
 report_status "getting hostname"
 
-server=`ec2-describe-instances \
+server="`ec2-describe-instances \
 --region $region \
 $instance \
 --filter instance-state-name=running \
-| grep "^INSTANCE" \
-| awk '{ print $4 }'`
+| grep '^INSTANCE' \
+| awk '{ print $4 }'`"
 
 report_status "hostname = $server"
 
 
 report_status "get volume on which gentoo was installed"
 
-volume=`ec2-describe-volumes \
+volume="`ec2-describe-volumes \
 --region $region \
 --filter attachment.instance-id=$instance \
 --filter attachment.device=/dev/sdf \
-| grep "^VOLUME" \
-| awk '{ print $2 } '`
+| grep '^VOLUME' \
+| awk '{ print $2 } '`"
 
 if [ -z $AMI_TYPE ]; then
     name=${AMI_NAME:-${default_name}-`date --utc +%Y-%m-%d-%H-%M-%S`}
 
 report_status "creating snapshot"
 
-snapshot=`ec2-create-snapshot \
+snapshot="`ec2-create-snapshot \
 --region $region \
 $volume \
 --description $name \
-| awk '{ print $2 }'`
+| awk '{ print $2 }'`"
 
 report_status "checking if snapshot is done"
 
 report_status "register image"
 
 if [ $architecture = "i386" ]; then
-gentoo_image=`ec2-register \
+gentoo_image="`ec2-register \
 --region $region \
 --name $name \
---description "${building}" \
+--description \"${building}\" \
 --architecture $architecture \
 --kernel $latest_kernel \
 --root-device-name /dev/sda1 \
---block-device-mapping "/dev/sda1=$snapshot" \
---block-device-mapping "/dev/sda2=ephemeral0" \
---block-device-mapping "/dev/sda3=ephemeral1" \
-| awk '{ print $2 }'`
+--block-device-mapping \"/dev/sda1=$snapshot\" \
+--block-device-mapping '/dev/sda2=ephemeral0' \
+--block-device-mapping '/dev/sda3=ephemeral1' \
+| awk '{ print $2 }'`"
 else
-gentoo_image=`ec2-register \
+gentoo_image="`ec2-register \
 --region $region \
 --name $name \
---description "${building}" \
+--description \"${building}\" \
 --architecture $architecture \
 --kernel $latest_kernel \
 --root-device-name /dev/sda1 \
---block-device-mapping "/dev/sda1=$snapshot" \
---block-device-mapping "/dev/sdb=ephemeral0" \
---block-device-mapping "/dev/sdc=ephemeral1" \
---block-device-mapping "/dev/sdd=ephemeral2" \
---block-device-mapping "/dev/sde=ephemeral3" \
-| awk '{ print $2 }'`
+--block-device-mapping \"/dev/sda1=$snapshot\" \
+--block-device-mapping '/dev/sdb=ephemeral0' \
+--block-device-mapping '/dev/sdc=ephemeral1' \
+--block-device-mapping '/dev/sdd=ephemeral2' \
+--block-device-mapping '/dev/sde=ephemeral3' \
+| awk '{ print $2 }'`"
 fi
 
 report_status "image-id = $gentoo_image"
 
-gentoo_instance=`ec2-run-instances \
+gentoo_instance="`ec2-run-instances \
 --region $region \
 $gentoo_image \
 --group $group \
 --key $key \
 --instance-type t1.micro \
-| grep "^INSTANCE" \
-| awk '{ print $2 }'`
+| grep '^INSTANCE' \
+| awk '{ print $2 }'`"
 
 report_status "gentoo instance = $gentoo_instance"
 
 
 report_status "getting hostname"
 
-server=`ec2-describe-instances \
+server="`ec2-describe-instances \
 --region $region \
 $gentoo_instance \
 --filter instance-state-name=running \
-| grep "^INSTANCE" \
-| awk '{ print $4 }'`
+| grep '^INSTANCE' \
+| awk '{ print $4 }'`"
 
 report_status "hostname = $server"
 
 sleep 120
 
 report_status "checking connection"
-up_check=`ssh -o StrictHostKeyChecking=no -i $keyfile -t ec2-user@$server "uname -a" | wc -c`
+up_check="`ssh -o StrictHostKeyChecking=no -i $keyfile -t ec2-user@$server 'uname -a' | wc -c`"
 
 if [ $up_check -ne 0 ]; then
     report_status "connection successful"
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.