THE FINAL BOSS

This commit is contained in:
Pratham Patel 2023-07-29 13:02:14 +05:30
parent 5e04d68b4a
commit 06e3fea70b
No known key found for this signature in database

View File

@ -1,45 +1,45 @@
#!/usr/bin/env bash #!/usr/bin/env bash
REAL_USER=$(who am i | awk '{print $1}') set -x
APPLIANCE_NAME="Rocky-9-aarch64-minimal" APPLIANCE_NAME="Rocky-9-aarch64-minimal"
KICKSTARTER_FILENAME="${APPLIANCE_NAME}.ks" KICKSTARTER_FILENAME="${APPLIANCE_NAME}.ks"
IMAGE_NAME="${APPLIANCE_NAME}-$(date +%Y.%m.%d).raw"
COMPRESSED_IMAGE_NAME="${IMAGE_NAME}.zst"
if [[ ${EUID} -ne 0 ]]; then if [[ ${EUID} -ne 0 ]]; then
>&2 echo "ERROR: Please run this script as root" >&2 echo "ERROR: Please run this script as root"
exit 1 exit 1
fi fi
appliance-creator \ {
--config "${KICKSTARTER_FILENAME}" \ appliance-creator \
--name "${APPLIANCE_NAME}" \ --config "${KICKSTARTER_FILENAME}" \
--format raw \ --name "${APPLIANCE_NAME}" \
--no-compress \ --format raw \
--outdir "${PWD}" \ --no-compress \
--cache "/root/cache" \ --outdir "${PWD}" \
--debug \ --cache "/root/cache" \
--verbose \ --debug \
1> Rocky-9-aarch64-minimal.stdout.log \ --verbose
2> Rocky-9-aarch64-minimal.stderr.log # DO NOT USE THE '--checksum' OPTION BECAUSE, FOR SOME REASON
#--checksum # UTF8 ERRORS ARE GENERATED DURING IMAGE CREATION
# DO NOT USE THE '--checksum' OPTION BECAUSE, FOR SOME REASON # AND THE IMAGE CREATION STEP FAILS
# UTF8 ERRORS ARE GENERATED DURING IMAGE CREATION #--checksum \
# AND THE IMAGE CREATION STEP FAILS
if [[ -f "${APPLIANCE_NAME}-sda.raw" ]]; then if [[ -d "${APPLIANCE_NAME}" ]]; then
set -x
IMAGE_NAME="${APPLIANCE_NAME}-$(date +%Y.%m.%d).raw" pushd "${APPLIANCE_NAME}" || exit 1
COMPRESSED_IMAGE_NAME="${IMAGE_NAME}.zst" mv -v -f "${APPLIANCE_NAME}-sda.raw" "${IMAGE_NAME}"
zstd -9 -z "${IMAGE_NAME}"
touch "${APPLIANCE_NAME}-sda.raw" sha256sum "${IMAGE_NAME}" > "${IMAGE_NAME}.sha256"
mv -v "${APPLIANCE_NAME}-sda.raw" "${IMAGE_NAME}" sha512sum "${IMAGE_NAME}" > "${IMAGE_NAME}.sha512"
zstd -9 -z "${IMAGE_NAME}" sha256sum "${COMPRESSED_IMAGE_NAME}" > "${COMPRESSED_IMAGE_NAME}.sha256"
sha512sum "${COMPRESSED_IMAGE_NAME}" > "${COMPRESSED_IMAGE_NAME}.sha512"
popd || exit 1
sha256sum "${IMAGE_NAME}" > "${IMAGE_NAME}.sha256" echo 'DONE'
sha512sum "${IMAGE_NAME}" > "${IMAGE_NAME}.sha512" echo "Please chown '${APPLIANCE_NAME}/' if necessary"
fi
sha256sum "${COMPRESSED_IMAGE_NAME}" > "${COMPRESSED_IMAGE_NAME}.sha256" } 1> "${APPLIANCE_NAME}.1.stdout.log" 2> "${APPLIANCE_NAME}.2.stderr.log"
sha512sum "${COMPRESSED_IMAGE_NAME}" > "${COMPRESSED_IMAGE_NAME}.sha512"
chown -v "${REAL_USER}:${REAL_USER}" "${IMAGE_NAME}*"
fi