-
Notifications
You must be signed in to change notification settings - Fork 115
Expand file tree
/
Copy pathgenerate_dappnode_iso_ubuntu.sh
More file actions
executable file
·74 lines (61 loc) · 2.84 KB
/
generate_dappnode_iso_ubuntu.sh
File metadata and controls
executable file
·74 lines (61 loc) · 2.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
set -e
SCRIPTS_DIR=$(dirname "${BASH_SOURCE[0]}")
source ${SCRIPTS_DIR}/common_iso_generation.sh
BASE_ISO_NAME=ubuntu-24.04.3-live-server-amd64.iso
BASE_ISO_PATH="/images/${BASE_ISO_NAME}"
BASE_ISO_URL="https://releases.ubuntu.com/24.04/${BASE_ISO_NAME}"
BASE_ISO_SHASUM="c3514bf0056180d09376462a7a1b4f213c1d6e8ea67fae5c25099c6fd3d8274b ${BASE_ISO_PATH}"
DAPPNODE_ISO_NAME="${DAPPNODE_ISO_PREFIX}${BASE_ISO_NAME}"
DAPPNODE_ISO_PATH="/images/${DAPPNODE_ISO_NAME}"
get_efi_partition() {
local base_iso_path=$1
local dest_efi_path=$2
local block_size=512
local efi_start=$(fdisk -l ${base_iso_path} | grep 'Appended2' | awk '{print $2}')
local efi_end=$(fdisk -l ${base_iso_path} | grep 'Appended2' | awk '{print $3}')
local efi_size=$(expr ${efi_end} - ${efi_start} + 1)
echo "[INFO] Obtaining the EFI partition image from ${efi_start} with size ${efi_size}..."
dd if=${base_iso_path} bs=${block_size} skip="$efi_start" count="$efi_size" of=${dest_efi_path}
}
add_ubuntu_autoinstall() {
local preseeds_dir=$1
local iso_build_path=$2
echo "[INFO] Adding preseed..."
if [[ $UNATTENDED == *"true"* ]]; then
cp ${preseeds_dir}/autoinstall_unattended.yaml ${iso_build_path}/autoinstall.yaml
else
cp ${preseeds_dir}/autoinstall.yaml ${iso_build_path}/autoinstall.yaml
fi
}
configure_boot_menu() {
echo "[INFO] Configuring the boot menu for Dappnode..."
cp -r /usr/src/app/iso/boot/ubuntu/* ${ISO_BUILD_PATH}/boot/grub/
}
generate_ubuntu_iso() {
local mbr_path=$1
local efi_path=$2
local iso_output_path=$3
local iso_build_path=$4
echo "[INFO] Creating the new Ubuntu ISO..."
mkisofs \
-rational-rock -joliet -joliet-long -full-iso9660-filenames \
-iso-level 3 -partition_offset 16 --grub2-mbr ${mbr_path} \
--mbr-force-bootable -append_partition 2 0xEF ${efi_path} \
-appended_part_as_gpt \
-eltorito-catalog /boot.catalog \
-eltorito-boot /boot/grub/i386-pc/eltorito.img -no-emul-boot -boot-load-size 4 \
-boot-info-table --grub2-boot-info -eltorito-alt-boot --efi-boot '--interval:appended_partition_2:all::' -no-emul-boot \
-o ${iso_output_path} ${iso_build_path}
}
download_iso "${BASE_ISO_PATH}" "${BASE_ISO_NAME}" "${BASE_ISO_URL}"
verify_download "${BASE_ISO_PATH}" "${BASE_ISO_SHASUM}"
clean_old_files "${ISO_BUILD_PATH}" "${DAPPNODE_ISO_PREFIX}"
extract_iso "${BASE_ISO_PATH}" "${ISO_BUILD_PATH}"
prepare_boot_process "${BASE_ISO_PATH}" "${ISO_BUILD_PATH}/mbr"
get_efi_partition "${BASE_ISO_PATH}" "${ISO_BUILD_PATH}/efi"
add_dappnode_files_to_iso_build "${ISO_BUILD_PATH}" "${WORKDIR}"
add_ubuntu_autoinstall "/usr/src/app/iso/preseeds/ubuntu" "${ISO_BUILD_PATH}"
configure_boot_menu
handle_checksums
generate_ubuntu_iso "${ISO_BUILD_PATH}/mbr" "${ISO_BUILD_PATH}/efi" "${DAPPNODE_ISO_PATH}" "${ISO_BUILD_PATH}"