examples/terraform: Add support for OEM images

This commit is contained in:
enilfodne
2017-05-17 00:53:55 +03:00
parent f6522a561b
commit 34d0f5003a
10 changed files with 55 additions and 1 deletions

View File

@@ -1,6 +1,9 @@
#!/bin/bash
# USAGE: ./scripts/get-coreos
# USAGE: ./scripts/get-coreos channel version dest
#
# ENV VARS:
# - OEM_ID - specify OEM image id to download, alongside the default one
set -eou pipefail
GPG=${GPG:-/usr/bin/gpg}
@@ -8,6 +11,7 @@ GPG=${GPG:-/usr/bin/gpg}
CHANNEL=${1:-"stable"}
VERSION=${2:-"1298.7.0"}
DEST_DIR=${3:-"$PWD/examples/assets"}
OEM_ID=${OEM_ID:-""}
DEST=$DEST_DIR/coreos/$VERSION
BASE_URL=https://$CHANNEL.release.core-os.net/amd64-usr/$VERSION
@@ -22,6 +26,16 @@ if [ ! -d "$DEST" ]; then
mkdir -p $DEST
fi
if [[ -n "${OEM_ID}" ]]; then
IMAGE_NAME="coreos_production_${OEM_ID}_image.bin.bz2"
# check if the oem version exists based on the header response
if ! curl -s -I $BASE_URL/$IMAGE_NAME | grep -q -E '^HTTP/[0-9.]+ [23][0-9][0-9]' ; then
echo "OEM version not found"
exit 1
fi
fi
echo "Downloading CoreOS $CHANNEL $VERSION images and sigs to $DEST"
echo "CoreOS Image Signing Key"
@@ -46,7 +60,20 @@ curl -# $BASE_URL/coreos_production_image.bin.bz2 -o $DEST/coreos_production_ima
echo "coreos_production_image.bin.bz2.sig"
curl -# $BASE_URL/coreos_production_image.bin.bz2.sig -o $DEST/coreos_production_image.bin.bz2.sig
# Install oem image
if [[ -n "${IMAGE_NAME-}" ]]; then
echo $IMAGE_NAME
curl -# $BASE_URL/$IMAGE_NAME -o $DEST/$IMAGE_NAME
echo "$IMAGE_NAME.sig"
curl -# $BASE_URL/$IMAGE_NAME.sig -o $DEST/$IMAGE_NAME.sig
fi
# verify signatures
$GPG --verify $DEST/coreos_production_pxe.vmlinuz.sig
$GPG --verify $DEST/coreos_production_pxe_image.cpio.gz.sig
$GPG --verify $DEST/coreos_production_image.bin.bz2.sig
# verify oem signature
if [[ -n "${IMAGE_NAME-}" ]]; then
$GPG --verify $DEST/$IMAGE_NAME.sig
fi