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,15 +1,19 @@
#!/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 \ {
appliance-creator \
--config "${KICKSTARTER_FILENAME}" \ --config "${KICKSTARTER_FILENAME}" \
--name "${APPLIANCE_NAME}" \ --name "${APPLIANCE_NAME}" \
--format raw \ --format raw \
@ -17,29 +21,25 @@ appliance-creator \
--outdir "${PWD}" \ --outdir "${PWD}" \
--cache "/root/cache" \ --cache "/root/cache" \
--debug \ --debug \
--verbose \ --verbose
1> Rocky-9-aarch64-minimal.stdout.log \
2> Rocky-9-aarch64-minimal.stderr.log
#--checksum
# DO NOT USE THE '--checksum' OPTION BECAUSE, FOR SOME REASON # DO NOT USE THE '--checksum' OPTION BECAUSE, FOR SOME REASON
# UTF8 ERRORS ARE GENERATED DURING IMAGE CREATION # UTF8 ERRORS ARE GENERATED DURING IMAGE CREATION
# AND THE IMAGE CREATION STEP FAILS # AND THE IMAGE CREATION STEP FAILS
#--checksum \
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}"
touch "${APPLIANCE_NAME}-sda.raw"
mv -v "${APPLIANCE_NAME}-sda.raw" "${IMAGE_NAME}"
zstd -9 -z "${IMAGE_NAME}" zstd -9 -z "${IMAGE_NAME}"
sha256sum "${IMAGE_NAME}" > "${IMAGE_NAME}.sha256" sha256sum "${IMAGE_NAME}" > "${IMAGE_NAME}.sha256"
sha512sum "${IMAGE_NAME}" > "${IMAGE_NAME}.sha512" sha512sum "${IMAGE_NAME}" > "${IMAGE_NAME}.sha512"
sha256sum "${COMPRESSED_IMAGE_NAME}" > "${COMPRESSED_IMAGE_NAME}.sha256" sha256sum "${COMPRESSED_IMAGE_NAME}" > "${COMPRESSED_IMAGE_NAME}.sha256"
sha512sum "${COMPRESSED_IMAGE_NAME}" > "${COMPRESSED_IMAGE_NAME}.sha512" sha512sum "${COMPRESSED_IMAGE_NAME}" > "${COMPRESSED_IMAGE_NAME}.sha512"
popd || exit 1
chown -v "${REAL_USER}:${REAL_USER}" "${IMAGE_NAME}*" echo 'DONE'
fi echo "Please chown '${APPLIANCE_NAME}/' if necessary"
fi
} 1> "${APPLIANCE_NAME}.1.stdout.log" 2> "${APPLIANCE_NAME}.2.stderr.log"