sbc-images/create-image.sh

41 lines
1.1 KiB
Bash
Raw Normal View History

2023-09-13 01:29:56 +00:00
#!/usr/bin/env bash
set -x
KICKSTART_BASE="Rocky"
TODAY="$(TZ='UTC' date +%Y.%m.%d)"
KICKSTART_FILE="${KICKSTART_BASE}.ks"
APPLIANCE_NAME="${KICKSTART_BASE}-$(dnf config-manager --dump-variables | grep releasever | awk '{print $3}')-$(uname -m)-minimal-${TODAY}"
IMAGE_NAME="${APPLIANCE_NAME}.raw"
COMMANDS_TO_CHECK=('appliance-creator' 'shasum' 'zstd')
for COMMAND in "${COMMANDS_TO_CHECK[@]}"; do
if ! command -v "${COMMAND}" > /dev/null; then
>&2 echo "$0: ERROR: unable to find command '${COMMAND}' in PATH"
2023-09-13 01:29:56 +00:00
exit 1
fi
done
appliance-creator \
--config "${KICKSTART_FILE}" \
--name "${APPLIANCE_NAME}" \
--format raw \
--outdir "${PWD}" \
--no-compress \
--debug \
--cache /root/cache \
--verbose 2>&1 | tee "${APPLIANCE_NAME}.log" || exit 1
if [[ -d "${APPLIANCE_NAME}" ]]; then
pushd "${APPLIANCE_NAME}" || exit 1
mv "${APPLIANCE_NAME}-sda.raw" "${IMAGE_NAME}"
popd || exit 0
else
>&2 echo "$0: ERROR: unable to find the appliance output directory"
>&2 echo "$0: ${APPLIANCE_NAME}"
exit 1
fi
2023-10-09 03:36:15 +00:00
if [[ -n "$1" ]]; then
chown "$1":"$1" -vR "${APPLIANCE_NAME}"
2023-10-09 03:36:15 +00:00
fi