Skip to content

Instantly share code, notes, and snippets.

@ncknt ncknt/download-bom.sh
Last active Sep 27, 2019

Embed
What would you like to do?
#!/bin/bash
# This script download a version of Armory's BOM to a local directory
# Usage: download.sh <version name> <destination path>
# Prerequisites:
# - aws cli: https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html
# - access to public s3 installed (no need for credentials)
# - write access to the destination path
# Change that
NEW_DOCKER_REGISTRY="docker.io/armory"
PGM=$0
VERSION=$1
DESTINATION_DIR=$2
ARMORY_BUCKET="halconfig"
ARMORY_BUCKET_REGION="us-west-2"
SERVICES="clouddriver echo gate orca igor deck fiat front50 kayenta rosco monitoring-daemon dinghy terraformer"
if [[ $# -lt 2 ]]; then
echo "Usage: ${PGM} <version name> <destination path>"
exit 1
fi
if [[ -f $DESTINATION_DIR ]]; then
echo "${DESTINATION_DIR} is a file."
exit 1
fi
mkdir -p ${DESTINATION_DIR}/bom
bom="${DESTINATION_DIR}/bom/${VERSION}.yml"
aws s3 cp --no-sign-request --region ${ARMORY_BUCKET_REGION} s3://${ARMORY_BUCKET}/bom/${VERSION}.yml ${bom}
for svc in $SERVICES; do
sv=$(grep -A 1 ${svc} ${bom} | awk '/version/ {print $2}' | cut -f1 -d"-")
sdir="$DESTINATION_DIR/profiles/${svc}/${sv}"
mkdir -p $sdir
aws s3 cp --no-sign-request --region ${ARMORY_BUCKET_REGION} --recursive --include "*" s3://${ARMORY_BUCKET}/profiles/${svc}/${sv}/ $sdir
done
sed -i '' "s/docker.io\\/armory/$(echo $NEW_DOCKER_REGISTRY | sed 's/\//\\\//g')/g" $bom
echo "\nVersion ${version} is ready to be uploaded to your private bucket."
echo "For example, with \"aws cp --recursive\" or \"gsutil cp -m -r ...\""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.