rocky-linux-generic-images/create-image.sh

56 lines
1.6 KiB
Bash
Raw Normal View History

2023-07-27 14:23:23 +00:00
#!/usr/bin/env bash
2023-07-29 07:32:14 +00:00
set -x
2023-07-27 14:23:23 +00:00
APPLIANCE_NAME="Rocky-9-aarch64-minimal"
KICKSTARTER_FILENAME="${APPLIANCE_NAME}.ks"
2023-07-29 07:47:09 +00:00
IMAGE_NAME="${APPLIANCE_NAME}-$(TZ='UTC' date +%Y.%m.%d-%H%M%S).raw"
2023-07-29 07:32:14 +00:00
COMPRESSED_IMAGE_NAME="${IMAGE_NAME}.zst"
2023-07-27 14:23:23 +00:00
if [[ ${EUID} -ne 0 ]]; then
2023-07-29 08:55:27 +00:00
>&2 echo "$0: error: Please run this script as root"
exit 1
fi
if ! command -v appliance-creator > /dev/null; then
>&2 echo "$0: error: unable to find command 'appliance-creator'"
exit 1
fi
if ! command -v shasum > /dev/null; then
>&2 echo "$0: error: unable to find command 'shasum'"
2023-07-27 14:23:23 +00:00
exit 1
fi
2023-07-29 07:32:14 +00:00
{
appliance-creator \
--config "${KICKSTARTER_FILENAME}" \
--name "${APPLIANCE_NAME}" \
--format raw \
--no-compress \
--outdir "${PWD}" \
--cache "/root/cache" \
--debug \
--verbose
# DO NOT USE THE '--checksum' OPTION BECAUSE, FOR SOME REASON
# UTF8 ERRORS ARE GENERATED DURING IMAGE CREATION
# AND THE IMAGE CREATION STEP FAILS
#--checksum \
if [[ -d "${APPLIANCE_NAME}" ]]; then
pushd "${APPLIANCE_NAME}" || exit 1
mv -v -f "${APPLIANCE_NAME}-sda.raw" "${IMAGE_NAME}"
zstd -9 -z "${IMAGE_NAME}"
sha256sum "${IMAGE_NAME}" > "${IMAGE_NAME}.sha256"
sha512sum "${IMAGE_NAME}" > "${IMAGE_NAME}.sha512"
sha256sum "${COMPRESSED_IMAGE_NAME}" > "${COMPRESSED_IMAGE_NAME}.sha256"
sha512sum "${COMPRESSED_IMAGE_NAME}" > "${COMPRESSED_IMAGE_NAME}.sha512"
popd || exit 1
echo 'DONE'
echo "Please chown '${APPLIANCE_NAME}/' if necessary"
fi
} 1> "${APPLIANCE_NAME}.1.stdout.log" 2> "${APPLIANCE_NAME}.2.stderr.log"