@@ -33,24 +33,26 @@ Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-a] [-u user-data-file] [-m me
3333
3434Available options:
3535
36- -h, --help Print this help and exit
37- -v, --verbose Print script debug info
38- -a, --all-in-one Bake user-data and meta-data into the generated ISO. By default you will
39- need to boot systems with a CIDATA volume attached containing your
40- autoinstall user-data and meta-data files.
41- For more information see: https://ubuntu.com/server/docs/install/autoinstall-quickstart
42- -u, --user-data Path to user-data file. Required if using -a
43- -m, --meta-data Path to meta-data file. Will be an empty file if not specified and using -a
44- -k, --no-verify Disable GPG verification of the source ISO file. By default SHA256SUMS-$today and
45- SHA256SUMS-$today .gpg in ${script_dir} will be used to verify the authenticity and integrity
46- of the source ISO file. If they are not present the latest daily SHA256SUMS will be
47- downloaded and saved in ${script_dir} . The Ubuntu signing key will be downloaded and
48- saved in a new keyring in ${script_dir}
49- -s, --source Source ISO file. By default the latest daily ISO for Ubuntu 20.04 will be downloaded
50- and saved as ${script_dir} /ubuntu-original-$today .iso
51- That file will be used by default if it already exists.
52- -d, --destination Destination ISO file. By default ${script_dir} /ubuntu-autoinstall-$today .iso will be
53- created, overwriting any existing file.
36+ -h, --help Print this help and exit
37+ -v, --verbose Print script debug info
38+ -a, --all-in-one Bake user-data and meta-data into the generated ISO. By default you will
39+ need to boot systems with a CIDATA volume attached containing your
40+ autoinstall user-data and meta-data files.
41+ For more information see: https://ubuntu.com/server/docs/install/autoinstall-quickstart
42+ -e, --use-hwe-kernel Force the generated ISO to boot using the hardware enablement (HWE) kernel. Not supported
43+ by early Ubuntu 20.04 release ISOs.
44+ -u, --user-data Path to user-data file. Required if using -a
45+ -m, --meta-data Path to meta-data file. Will be an empty file if not specified and using -a
46+ -k, --no-verify Disable GPG verification of the source ISO file. By default SHA256SUMS-$today and
47+ SHA256SUMS-$today .gpg in ${script_dir} will be used to verify the authenticity and integrity
48+ of the source ISO file. If they are not present the latest daily SHA256SUMS will be
49+ downloaded and saved in ${script_dir} . The Ubuntu signing key will be downloaded and
50+ saved in a new keyring in ${script_dir}
51+ -s, --source Source ISO file. By default the latest daily ISO for Ubuntu 20.04 will be downloaded
52+ and saved as ${script_dir} /ubuntu-original-$today .iso
53+ That file will be used by default if it already exists.
54+ -d, --destination Destination ISO file. By default ${script_dir} /ubuntu-autoinstall-$today .iso will be
55+ created, overwriting any existing file.
5456EOF
5557 exit
5658}
@@ -63,12 +65,14 @@ function parse_params() {
6365 destination_iso=" ${script_dir} /ubuntu-autoinstall-$today .iso"
6466 gpg_verify=1
6567 all_in_one=0
68+ use_hwe_kernel=0
6669
6770 while : ; do
6871 case " ${1-} " in
6972 -h | --help) usage ;;
7073 -v | --verbose) set -x ;;
7174 -a | --all-in-one) all_in_one=1 ;;
75+ -e | --use-hwe-kernel) use_hwe_kernel=1 ;;
7276 -k | --no-verify) gpg_verify=0 ;;
7377 -u | --user-data)
7478 user_data_file=" ${2-} "
@@ -124,11 +128,11 @@ else
124128fi
125129
126130log " 🔎 Checking for required utilities..."
127- [[ ! -x " $( command -v 7z) " ]] && die " 💥 7z is not installed."
128- [[ ! -x " $( command -v sed) " ]] && die " 💥 sed is not installed."
129- [[ ! -x " $( command -v curl) " ]] && die " 💥 curl is not installed."
130- [[ ! -x " $( command -v mkisofs) " ]] && die " 💥 mkisofs is not installed."
131- [[ ! -x " $( command -v gpg) " ]] && die " 💥 gpg is not installed."
131+ [[ ! -x " $( command -v 7z) " ]] && die " 💥 7z is not installed. On Ubuntu, install the 'p7zip-full' package. "
132+ [[ ! -x " $( command -v sed) " ]] && die " 💥 sed is not installed. On Ubuntu, install the 'sed' package. "
133+ [[ ! -x " $( command -v curl) " ]] && die " 💥 curl is not installed. On Ubuntu, install the 'curl' package. "
134+ [[ ! -x " $( command -v mkisofs) " ]] && die " 💥 mkisofs is not installed. On Ubuntu, install the 'genisoimage' package. "
135+ [[ ! -x " $( command -v gpg) " ]] && die " 💥 gpg is not installed. On Ubuntu, install the 'gpg' package. "
132136log " 👍 All required utilities are installed."
133137
134138if [ ! -f " ${source_iso} " ]; then
@@ -186,6 +190,20 @@ log "🔧 Extracting ISO image..."
186190rm -rf " $tmpdir /" ' [BOOT]'
187191log " 👍 Extracted to $tmpdir "
188192
193+ if [ ${use_hwe_kernel} -eq 1 ]; then
194+ if grep -q " hwe-vmlinuz" " $tmpdir /boot/grub/grub.cfg" ; then
195+ log " ☑️ Destination ISO will use HWE kernel."
196+ sed -i -e ' s|/casper/vmlinuz|/casper/hwe-vmlinuz|g' " $tmpdir /isolinux/txt.cfg"
197+ sed -i -e ' s|/casper/initrd|/casper/hwe-initrd|g' " $tmpdir /isolinux/txt.cfg"
198+ sed -i -e ' s|/casper/vmlinuz|/casper/hwe-vmlinuz|g' " $tmpdir /boot/grub/grub.cfg"
199+ sed -i -e ' s|/casper/initrd|/casper/hwe-initrd|g' " $tmpdir /boot/grub/grub.cfg"
200+ sed -i -e ' s|/casper/vmlinuz|/casper/hwe-vmlinuz|g' " $tmpdir /boot/grub/loopback.cfg"
201+ sed -i -e ' s|/casper/initrd|/casper/hwe-initrd|g' " $tmpdir /boot/grub/loopback.cfg"
202+ else
203+ log " ⚠️ This source ISO does not support the HWE kernel. Proceeding with the regular kernel."
204+ fi
205+ fi
206+
189207log " 🧩 Adding autoinstall parameter to kernel command line..."
190208sed -i -e ' s/---/ autoinstall ---/g' " $tmpdir /isolinux/txt.cfg"
191209sed -i -e ' s/---/ autoinstall ---/g' " $tmpdir /boot/grub/grub.cfg"
0 commit comments