coreos / fedora-coreos-docs

Documentation for Fedora CoreOS
https://docs.fedoraproject.org/en-US/fedora-coreos/
Other
51 stars 124 forks source link

Script to "convert" an existing image for a platform where we don't provide ready made images #651

Closed travier closed 4 months ago

travier commented 4 months ago

I'll make this into a doc page. Can be run from COSA for example.

#!/bin/bash

set -euo pipefail
# set -x

if [[ ${#} -ne 3 ]]; then
    echo "Usage: <source image> <dest image> <platform>"
    echo ""
    echo "Example:"
    echo "./$(basename "${0}") fedora-coreos-40.20240616.3.0-{qemu,heztner}.x86_64.qcow2 heztner"
    exit 1
fi

source="${1}"
dest="${2}"
platform="${3}"

if [[ ! -f "${source}" ]]; then
    echo "Source image ${source} does not exists"
    exit 1
fi

if [[ -f "${dest}" ]]; then
    echo "Destination image ${dest} already exists"
    exit 1
fi

cp --reflink=auto "${source}" "${dest}"
guestfish -a "${dest}" <<EOF
run
mount /dev/sda3 /
download /loader/entries/ostree-1.conf tmp.loader.entries.ostree-1.conf
<! sed -i "s/ignition.platform.id=qemu/ignition.platform.id=${platform}/" tmp.loader.entries.ostree-1.conf
upload tmp.loader.entries.ostree-1.conf /loader/entries/ostree-1.conf
EOF

rm -v ./tmp.loader.entries.ostree-1.conf

echo "Done"
travier commented 4 months ago

Merging that into the docs pages directly for now.