Skip to content

Commit bbdcce0

Browse files
committed
feat: variable image name
1 parent 96c534a commit bbdcce0

2 files changed

Lines changed: 25 additions & 13 deletions

File tree

‎image-factory/create_image.sh‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,22 @@ image_version() {
5656
}
5757

5858
export DOCKER_CONTEXT=default
59+
OUTPUT_DIR="/output"
5960

60-
IMAGE="/output/image.img"
61-
#IMAGE_QCOW="/output/image.qcow2"
61+
if [[ ! -d "${OUTPUT_DIR}" ]]; then
62+
echo "Build dir does not exist."
63+
exit 1
64+
fi
65+
66+
IMAGE_NAME="${IMAGE_NAME:-"image"}"
67+
IMAGE="${OUTPUT_DIR}/${IMAGE_NAME}.img"
6268

63-
if [[ ! -d "/output" ]]; then
69+
if [[ ! -d "${OUTPUT_DIR}" ]]; then
6470
echo "Output dir not mounted"
6571
exit 1
6672
fi
6773

68-
export CONFIG_PATH="/output/system.json"
74+
export CONFIG_PATH="${OUTPUT_DIR}/${IMAGE_NAME}.json"
6975
if [[ ! -f "${CONFIG_PATH}" ]]; then
7076
echo "Config file not found: ${CONFIG_PATH}"
7177
exit 1

‎installer-factory/create_iso.sh‎

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,34 +11,40 @@ if [[ ! -d "${OUTPUT_DIR}" ]]; then
1111
echo "Build dir does not exist."
1212
exit 1
1313
fi
14-
if [[ ! -f "${OUTPUT_DIR}/image.img" ]]; then
14+
15+
export DOCKER_CONTEXT=default
16+
IMAGE_NAME="${IMAGE_NAME:-"installer"}"
17+
INSTALLER="${OUTPUT_DIR}/${IMAGE_NAME}.iso"
18+
IMAGE="${OUTPUT_DIR}/${IMAGE_NAME}.img"
19+
20+
if [[ ! -f "${IMAGE}" ]]; then
1521
echo "Image file does not exist."
1622
exit 1
1723
fi
1824

19-
export DOCKER_CONTEXT=default
25+
rm -f "${INSTALLER}"
2026

21-
rm -f "${OUTPUT_DIR}/installer.iso"
27+
export CONFIG_PATH="${OUTPUT_DIR}/${IMAGE_NAME}.json"
2228

2329
# compress image using zstd (multi-threaded, level 9) and copy to the ISO dir
2430
# choose level 9 as a balance between compression ratio and build time; adjust as desired
25-
zstd -T0 -9 -c "${OUTPUT_DIR}/image.img" > "${ISO_DIR}/image.img.zst"
31+
zstd -T0 -9 -c "${IMAGE}" > "${ISO_DIR}/image.img.zst"
2632

27-
if [[ -f "${OUTPUT_DIR}/system.json" ]]; then
28-
cp "${OUTPUT_DIR}/system.json" "${ISO_DIR}"
33+
if [[ -f "${CONFIG_PATH}" ]]; then
34+
cp "${CONFIG_PATH}" "${ISO_DIR}/system.json"
2935

30-
if jq -e '.installer_auto_overwrite_disk == true' "${OUTPUT_DIR}/system.json" > /dev/null; then
36+
if jq -e '.installer_auto_overwrite_disk == true' "${CONFIG_PATH}" > /dev/null; then
3137
touch "${ISO_DIR}/installer_auto_overwrite_disk.txt"
3238
fi
3339

3440
fi
3541

3642
grub-mkrescue \
37-
-o "${OUTPUT_DIR}/installer.iso" \
43+
-o "${INSTALLER}" \
3844
-V "${VOLID}" \
3945
-iso-level 3 \
4046
-full-iso9660-filenames \
4147
"${ISO_DIR}" || exit 1
4248

4349
echo "ISO creation complete."
44-
echo "Installer written to ${OUTPUT_DIR/\//}/installer.iso"
50+
echo "Installer written to ${INSTALLER/\//}"

0 commit comments

Comments
 (0)