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

43 lines
1.1 KiB
Bash
Raw Normal View History

2023-07-27 14:23:23 +00:00
#!/usr/bin/env bash
REAL_USER=$(who am i | awk '{print $1}')
APPLIANCE_NAME="Rocky-9-aarch64-minimal"
KICKSTARTER_FILENAME="${APPLIANCE_NAME}.ks"
if [[ ${EUID} -ne 0 ]]; then
>&2 echo "ERROR: Please run this script as root"
exit 1
fi
appliance-creator \
--config "${KICKSTARTER_FILENAME}" \
--name "${APPLIANCE_NAME}" \
--format raw \
--checksum \
--no-compress \
--outdir "${PWD}" \
2023-07-27 14:33:48 +00:00
--cache "/root/cache" \
2023-07-27 14:23:23 +00:00
--debug \
--verbose \
1> Rocky-9-aarch64-minimal.stdout.log \
2> Rocky-9-aarch64-minimal.stderr.log
if [[ -f "${APPLIANCE_NAME}-sda.raw" ]]; then
2023-07-28 06:40:01 +00:00
set -x
IMAGE_NAME="${APPLIANCE_NAME}-$(date +%Y.%m.%d).raw"
COMPRESSED_IMAGE_NAME="${IMAGE_NAME}.zst"
touch "${APPLIANCE_NAME}-sda.raw"
2023-07-28 08:25:52 +00:00
mv -v "${APPLIANCE_NAME}-sda.raw" "${IMAGE_NAME}"
2023-07-28 06:40:01 +00:00
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"
chown -v "${REAL_USER}:${REAL_USER}" "${IMAGE_NAME}*"
2023-07-27 15:11:45 +00:00
fi