Skip to content

Instantly share code, notes, and snippets.

@kyl191
Last active June 16, 2018 20:26
Show Gist options
  • Save kyl191/f65d31e56fa788e6fe0cd6559d7b48ff to your computer and use it in GitHub Desktop.
Save kyl191/f65d31e56fa788e6fe0cd6559d7b48ff to your computer and use it in GitHub Desktop.
Fedora on GCE
#!/bin/bash
set -e
# Get the image - Image must be names disk.raw
curl -L https://download.fedoraproject.org/pub/fedora/linux/releases/28/Cloud/x86_64/images/Fedora-Cloud-Base-28-1.1.x86_64.raw.xz | xz --decompress > disk.raw
# Create the temp bucket to hold the file
export BUCKET=$(cat /dev/urandom| tr -dc 'a-z0-9' | fold -w 32 | head -n 1)
gsutil mb gs://${BUCKET}
# tar & compress the file and upload it
export TARFILE=Fedora-Cloud-Base-28.tar.gz
tar -Sczf ${TARFILE} disk.raw && gsutil mv ${TARFILE} gs://${BUCKET}
# Register the image in GCE
gcloud compute images create fedora-cloud-28 --source-uri gs://${BUCKET}/${TARFILE}
# Cleanup after ourselves
gsutil rm gs://${BUCKET}/${TARFILE}
gsutil rb gs://${BUCKET}
rm disk.raw
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment