From 2f93bdbd54e4c84f98d3950a6aae0427f4161d1c Mon Sep 17 00:00:00 2001 From: Michael Marineau Date: Mon, 9 Jun 2014 11:36:41 -0700 Subject: [PATCH] fix(oem/ami): Add option to copy to a single region. It is not uncommon for a single region to fail with some internal server error or other transient issue. Make it easy to fix up that one region. --- oem/ami/copy_ami.sh | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/oem/ami/copy_ami.sh b/oem/ami/copy_ami.sh index daed96a095..067261eff9 100755 --- a/oem/ami/copy_ami.sh +++ b/oem/ami/copy_ami.sh @@ -38,14 +38,24 @@ AMI= VER= BOARD="amd64-usr" GROUP="alpha" +REGIONS=() -while getopts "a:V:b:g:hv" OPTION +add_region() { + if [[ -z "${AKI[$1]}" ]]; then + echo "Invalid region '$1'" >&2; + exit 1 + fi + REGIONS+=( "$1" ) +} + +while getopts "a:V:b:g:r:hv" OPTION do case $OPTION in a) AMI="$OPTARG";; V) VER="$OPTARG";; b) BOARD="$OPTARG";; g) GROUP="$OPTARG";; + r) add_region "$OPTARG";; h) echo "$USAGE"; exit;; v) set -x;; *) exit 1;; @@ -77,6 +87,10 @@ else fi fi +if [[ ${#REGIONS[@]} -eq 0 ]]; then + REGIONS=( "${!AKI[@]}" ) +fi + # The name has a limited set of allowed characterrs name=$(sed -e "s%[^A-Za-z0-9()\\./_-]%_%g" <<< "CoreOS-$GROUP-$VER") description="CoreOS $GROUP $VER" @@ -113,7 +127,7 @@ do_copy() { ec2-modify-image-attribute --region "$r" "$r_amiid" --launch-permission -a all } -for r in "${!AKI[@]}" +for r in "${REGIONS[@]}" do [ "${r}" == "${region}" ] && continue echo "Starting copy of $AMI from $region to $r"