-
Notifications
You must be signed in to change notification settings - Fork 3
/
get-coreos
executable file
·52 lines (42 loc) · 1.93 KB
/
get-coreos
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
# USAGE: ./scripts/get-coreos
# USAGE: ./scripts/get-coreos channel version dest
set -eou pipefail
GPG=${GPG:-/usr/bin/gpg}
CHANNEL=${1:-"stable"}
VERSION=${2:-"1520.8.0"}
DEST_DIR=${3:-"$PWD/assets"}
DEST=$DEST_DIR/coreos/$VERSION
BASE_URL=https://$CHANNEL.release.core-os.net/amd64-usr/$VERSION
# check channel/version exist based on the header response
if ! curl -s -I $BASE_URL/coreos_production_pxe.vmlinuz | grep -q -E '^HTTP/[0-9.]+ [23][0-9][0-9]' ; then
echo "Channel or Version not found"
exit 1
fi
if [ ! -d "$DEST" ]; then
echo "Creating directory $DEST"
mkdir -p $DEST
fi
echo "Downloading CoreOS $CHANNEL $VERSION images and sigs to $DEST"
echo "CoreOS Image Signing Key"
curl -# https://coreos.com/security/image-signing-key/CoreOS_Image_Signing_Key.asc -o $DEST/CoreOS_Image_Signing_Key.asc
$GPG --import < "$DEST/CoreOS_Image_Signing_Key.asc" || true
# PXE kernel and sig
echo "coreos_production_pxe.vmlinuz..."
curl -# $BASE_URL/coreos_production_pxe.vmlinuz -o $DEST/coreos_production_pxe.vmlinuz
echo "coreos_production_pxe.vmlinuz.sig"
curl -# $BASE_URL/coreos_production_pxe.vmlinuz.sig -o $DEST/coreos_production_pxe.vmlinuz.sig
# PXE initrd and sig
echo "coreos_production_pxe_image.cpio.gz"
curl -# $BASE_URL/coreos_production_pxe_image.cpio.gz -o $DEST/coreos_production_pxe_image.cpio.gz
echo "coreos_production_pxe_image.cpio.gz.sig"
curl -# $BASE_URL/coreos_production_pxe_image.cpio.gz.sig -o $DEST/coreos_production_pxe_image.cpio.gz.sig
# Install image
echo "coreos_production_image.bin.bz2"
curl -# $BASE_URL/coreos_production_image.bin.bz2 -o $DEST/coreos_production_image.bin.bz2
echo "coreos_production_image.bin.bz2.sig"
curl -# $BASE_URL/coreos_production_image.bin.bz2.sig -o $DEST/coreos_production_image.bin.bz2.sig
# 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