@@ -13,12 +13,20 @@ check_root() {
1313  fi 
1414}
1515
16- check_ubuntu () {
17-   #  Currently this script only works on Ubuntu instances
18-   if  !  grep -qi ' ubuntu'   /etc/os-release;  then 
19-     echo  " This script currently only works on Ubuntu." 
20-     exit  1
16+ check_userspace () {
17+   #  Currently this script only works on Ubuntu and AL2023
18+   if  grep -qi ' ubuntu'   /etc/os-release;  then 
19+     USERSPACE=" UBUNTU" 
20+     return  0
21+   fi 
22+ 
23+   if  grep -qi ' al2023'   /etc/os-release;  then 
24+     USERSPACE=" AL2023" 
25+     return  0
2126  fi 
27+ 
28+   echo  " This script currently only works on Ubuntu and Amazon Linux 2023." 
29+   exit  1
2230}
2331
2432tidy_up () {
@@ -96,6 +104,39 @@ check_override_presence() {
96104  echo  " All overrides correctly applied.." 
97105}
98106
107+ ubuntu_update_boot () {
108+   echo  " Update initramfs" 
109+   update-initramfs -c -k $KERNEL_VERSION 
110+   echo  " Updating GRUB..." 
111+   update-grub
112+ }
113+ 
114+ al2023_update_boot () {
115+   echo  " Installing ENA driver for AL2023" 
116+   $START_DIR /install_ena.sh $KERNEL_VERSION  $START_DIR /dkms.conf
117+ 
118+   #  Just ensure we are back in the build dir
119+   cd  $TMP_BUILD_DIR 
120+ 
121+   echo  " Creating the new ram disk" 
122+   dracut --kver $KERNEL_VERSION  -f -v
123+ 
124+   echo  " Updating GRUB..." 
125+   grubby --grub2 --add-kernel /boot/vmlinux-$KERNEL_VERSION  --title=" Secret Hiding"   --initrd=/boot/initramfs-$KERNEL_VERSION .img --copy-default
126+   grubby --set-default /boot/vmlinux-$KERNEL_VERSION 
127+ }
128+ 
129+ update_boot_config () {
130+   case  " $USERSPACE "   in 
131+   UBUNTU) ubuntu_update_boot ;;
132+   AL2023) al2023_update_boot ;;
133+   * )
134+     echo  " Unknown userspace" 
135+     exit  1
136+     ;;
137+   esac 
138+ }
139+ 
99140KERNEL_URL=$( cat kernel_url) 
100141KERNEL_COMMIT_HASH=$( cat kernel_commit_hash) 
101142KERNEL_PATCHES_DIR=$( pwd)  /patches
@@ -155,16 +196,14 @@ echo "New kernel version:" $KERNEL_VERSION
155196confirm " $@ " 
156197
157198check_root
158- check_ubuntu 
199+ check_userspace 
159200
160201echo  " Installing kernel modules..." 
161202make INSTALL_MOD_STRIP=1 modules_install
162203echo  " Installing kernel..." 
163204make INSTALL_MOD_STRIP=1 install
164- echo  " Update initramfs" 
165- update-initramfs -c -k $KERNEL_VERSION 
166- echo  " Updating GRUB..." 
167- update-grub
205+ 
206+ update_boot_config
168207
169208echo  " Kernel built and installed successfully!" 
170209
0 commit comments