From cb38d3125b81470436a4f60a83d0c8e52d9a47c4 Mon Sep 17 00:00:00 2001 From: Euan Kemp Date: Wed, 14 Jun 2017 16:20:03 -0700 Subject: [PATCH] offline_signing: take download channel as an arg A validation for the channel variable was also added so old users of the 3-argument form would get a sensical error if they used a invocation from their history. --- offline_signing/download.sh | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/offline_signing/download.sh b/offline_signing/download.sh index 1b6c099703..bf46eb70e9 100755 --- a/offline_signing/download.sh +++ b/offline_signing/download.sh @@ -1,11 +1,20 @@ #!/usr/bin/env bash -set -ex -BOARD="$1" -VERSION="$2" -GS="gs://builds.release.core-os.net/stable/boards/$BOARD/$VERSION" +set -eux -cd "${3:-.}" +BOARD="${1?Must provide a board (e.g. amd64-usr)}" +VERSION="${2?Must provide a version (e.g. 1234.0.0)}" +CHANNEL="${3?Must provide a channel (e.g. alpha)}" + +if ! [[ "${CHANNEL}" =~ alpha|beta|stable ]]; then + echo "Invalid channel ${CHANNEL}" + echo "Usage: $0 [OUTPUT DIR]" + exit 1 +fi + +GS="gs://builds.release.core-os.net/${CHANNEL}/boards/$BOARD/$VERSION" + +cd "${4:-.}" gsutil cp \ "${GS}/coreos_production_image.vmlinuz" \