Created
May 12, 2026 14:12
-
-
Save bjwschaap/0ac4cc5de8a18bc43387c2349fe4aa21 to your computer and use it in GitHub Desktop.
Matchbox get-fedora-coreos script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # USAGE: ./scripts/get-flatcar | |
| # USAGE: ./scripts/get-flatcar channel version dest arch | |
| # | |
| # ENV VARS: | |
| # - OEM_ID - specify OEM image id to download, alongside the default one | |
| set -eou pipefail | |
| GPG=${GPG:-/usr/bin/gpg} | |
| CHANNEL=${1:-"stable"} | |
| VERSION=${2:-"current"} | |
| DEST_DIR=${3:-"$PWD/examples/assets"} | |
| ARCH=${4:-"amd64"} | |
| OEM_ID=${OEM_ID:-""} | |
| DEST=$DEST_DIR/flatcar/$VERSION | |
| BASE_URL=https://$CHANNEL.release.flatcar-linux.net/${ARCH}-usr/$VERSION | |
| echo "Base URL: ${BASE_URL}" | |
| # check channel/version exist based on the header response | |
| if ! curl -s -I "${BASE_URL}/flatcar_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 | |
| if [[ -n "${OEM_ID}" ]]; then | |
| IMAGE_NAME="flatcar_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 Flatcar Linux $CHANNEL $VERSION images and sigs to $DEST" | |
| echo "Flatcar Linux Image Signing Key" | |
| curl -f# https://www.flatcar.org/security/image-signing-key/Flatcar_Image_Signing_Key.asc -o "${DEST}/Flatcar_Image_Signing_Key.asc" | |
| $GPG --import <"$DEST/Flatcar_Image_Signing_Key.asc" || true | |
| # Version | |
| echo "version.txt" | |
| curl -f# -L "${BASE_URL}/version.txt" -o "${DEST}/version.txt" | |
| # PXE kernel and sig | |
| echo "flatcar_production_pxe.vmlinuz..." | |
| curl -f# -L "${BASE_URL}/flatcar_production_pxe.vmlinuz" -o "${DEST}/flatcar_production_pxe.vmlinuz" | |
| echo "flatcar_production_pxe.vmlinuz.sig" | |
| curl -f# -L "${BASE_URL}/flatcar_production_image.vmlinuz.sig" -o "${DEST}/flatcar_production_pxe.vmlinuz.sig" | |
| # PXE initrd and sig | |
| echo "flatcar_production_pxe_image.cpio.gz" | |
| curl -f# -L "${BASE_URL}/flatcar_production_pxe_image.cpio.gz" -o "${DEST}/flatcar_production_pxe_image.cpio.gz" | |
| echo "flatcar_production_pxe_image.cpio.gz.sig" | |
| curl -f# -L "${BASE_URL}/flatcar_production_pxe_image.cpio.gz.sig" -o "${DEST}/flatcar_production_pxe_image.cpio.gz.sig" | |
| # Install image | |
| echo "flatcar_production_image.bin.bz2" | |
| curl -f# -L "${BASE_URL}/flatcar_production_image.bin.bz2" -o "${DEST}/flatcar_production_image.bin.bz2" | |
| echo "flatcar_production_image.bin.bz2.sig" | |
| curl -f# -L "${BASE_URL}/flatcar_production_image.bin.bz2.sig" -o "${DEST}/flatcar_production_image.bin.bz2.sig" | |
| # Install oem image | |
| if [[ -n "${IMAGE_NAME-}" ]]; then | |
| echo "${IMAGE_NAME}" | |
| curl -f# -L "${BASE_URL}/${IMAGE_NAME}" -o "${DEST}/${IMAGE_NAME}" | |
| echo "${IMAGE_NAME}.sig" | |
| curl -f# -L "${BASE_URL}/${IMAGE_NAME}.sig" -o "${DEST}/${IMAGE_NAME}.sig" | |
| fi | |
| # verify signatures | |
| $GPG --verify "${DEST}/flatcar_production_pxe.vmlinuz.sig" | |
| $GPG --verify "${DEST}/flatcar_production_pxe_image.cpio.gz.sig" | |
| $GPG --verify "${DEST}/flatcar_production_image.bin.bz2.sig" | |
| # verify oem signature | |
| if [[ -n "${IMAGE_NAME-}" ]]; then | |
| $GPG --verify "${DEST}/${IMAGE_NAME}.sig" | |
| fi | |
| root@matchbox:~/matchbox/scripts# cat get-fedora-coreos | |
| #!/usr/bin/env bash | |
| # USAGE: ./scripts/get-fedora-coreos | |
| # USAGE: ./scripts/get-fedora-coreos stream version dest | |
| # | |
| set -eou pipefail | |
| STREAM=${1:-"stable"} | |
| VERSION=${2:-"36.20220906.3.2"} | |
| DEST_DIR=${3:-"$PWD/examples/assets"} | |
| ARCH=${4:-"x64_64"} | |
| DEST=$DEST_DIR/fedora-coreos | |
| BASE_URL=https://builds.coreos.fedoraproject.org/prod/streams/$STREAM/builds/$VERSION/$ARCH | |
| # check stream/version exist based on the header response | |
| if ! curl -s -I $BASE_URL/fedora-coreos-$VERSION-metal.${ARCH}.raw.xz | grep -q -E '^HTTP/[0-9.]+ [23][0-9][0-9]' ; then | |
| echo "Stream or Version not found" | |
| exit 1 | |
| fi | |
| if [ ! -d "$DEST" ]; then | |
| echo "Creating directory $DEST" | |
| mkdir -p $DEST | |
| fi | |
| echo "Downloading Fedora CoreOS $STREAM $VERSION $ARCH images to $DEST" | |
| # PXE kernel | |
| # https://builds.coreos.fedoraproject.org/prod/streams/stable/builds/44.20260419.3.1/aarch64/fedora-coreos-44.20260419.3.1-live-kernel.aarch64 | |
| echo "fedora-coreos-$VERSION-live-kernel.${ARCH}" | |
| curl -f# -L $BASE_URL/fedora-coreos-$VERSION-live-kernel.${ARCH} -o $DEST/fedora-coreos-$VERSION-live-kernel-${ARCH} | |
| # PXE initrd | |
| echo "fedora-coreos-$VERSION-live-initramfs.${ARCH}.img" | |
| curl -f# -L $BASE_URL/fedora-coreos-$VERSION-live-initramfs.${ARCH}.img -o $DEST/fedora-coreos-$VERSION-live-initramfs.${ARCH}.img | |
| # rootfs | |
| echo "fedora-coreos-$VERSION-live-rootfs.${ARCH}.img" | |
| curl -f# -L $BASE_URL/fedora-coreos-$VERSION-live-rootfs.${ARCH}.img -o $DEST/fedora-coreos-$VERSION-live-rootfs.${ARCH}.img |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment