Skip to content

Commit be307fb

Browse files
Upgrade issue fix (#130)
Co-authored-by: vthiruveedula <[email protected]>
1 parent 3542bf8 commit be307fb

File tree

2 files changed

+40
-54
lines changed

2 files changed

+40
-54
lines changed

standalone-node/provisioning_scripts/install-os.sh

Lines changed: 29 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -409,21 +409,17 @@ EOT
409409

410410
# Change the boot order to disk
411411
boot_order_chage_to_disk() {
412-
echo -e "${BLUE}Changing the Boot order to disk!!${NC}"
413-
414-
boot_entry="Emt"
415-
efiboot_part=1
416-
EFI=""
412+
echo -e "${BLUE}Changing the Boot order to disk!!${NC}"
417413

418414
# Delete the pile up Ubuntu/Emt partitions from BIOS bootMenu
419-
for bootnumber in $(efibootmgr | grep -iE "emt|Ubuntu" | awk '{print $1}' | sed 's/Boot//;s/\*//'); do
415+
for bootnumber in $(efibootmgr | grep -iE "Linux Boot Manager|Ubuntu" | awk '{print $1}' | sed 's/Boot//;s/\*//'); do
420416
efibootmgr -b "$bootnumber" -B
421417
done
422418
# Delete the duplicate boot entries from bootmenu
423419
boot_order=$(efibootmgr -D)
424420
echo "$boot_order"
425421

426-
# Get the rootfs
422+
# Get the rootfs
427423
rootfs=$(blkid | grep -Ei 'TYPE="ext4"' | grep -Ei 'LABEL="rootfs"' | awk -F: '{print $1}')
428424

429425
efiboot=$(blkid | grep -Ei 'TYPE="vfat"' | grep -Ei 'LABEL="esp|uefi"' | awk -F: '{print $1}')
@@ -434,45 +430,37 @@ boot_order_chage_to_disk() {
434430
osdisk=$(echo "$rootfs" | grep -oE 'sd[a-z]+' | head -n 1)
435431
fi
436432

433+
# Mount all required partitions to create bootctl install entry
437434
check_mnt_mount_exist
438-
mount "${rootfs}" /mnt
439-
mount "$efiboot" /mnt/boot/efi
440-
441-
# Get the EFI boot from chroot
442-
EFI=$(chroot /mnt sh -c "basename \$(find /boot/efi/EFI/Linux -type f -iname '*.efi' | head -n1)") || { echo "EFI binary not present,please check"; return 1; }
443-
444-
# Unmount the file systems
445-
umount /mnt/boot/efi
446-
umount /mnt
447-
448-
# Create the boot entry
449-
new_boot_number=$(efibootmgr -c -d "/dev/${osdisk}" -p $efiboot_part -L "$boot_entry" -l "\\EFI\\Linux\\$EFI") || { echo "Failed to create new boot entry"; return 1; }
450435

451-
echo "Successfully created the boot entry $efiboot_part"
452-
453-
new_boot_number=$(efibootmgr | grep -i Emt | grep -oP 'Boot\d{4}' | head -n1 | sed 's/Boot//')
454-
455-
echo "New boot number is $new_boot_number"
456-
457-
# Update the bootorder
458-
usb_boot_number=$(efibootmgr | grep -i "Bootcurrent" | awk '{print $2}')
436+
mount "${rootfs}" /mnt
437+
mount $efiboot /mnt/boot/efi
438+
mount --bind /dev /mnt/dev
439+
mount --bind /dev/pts /mnt/dev/pts
440+
mount --bind /proc /mnt/proc
441+
mount --bind /sys /mnt/sys
442+
mount --bind /sys/firmware/efi/efivars /mnt/sys/firmware/efi/efivars
459443

460-
boot_order_cur=$(efibootmgr | grep -i "Bootorder" | awk '{print $2}')
444+
chroot /mnt /bin/bash <<EOT
445+
set -e
446+
bootctl install
447+
EOT
461448

462-
if [ -n "$boot_order_cur" ]; then
463-
final_boot_order="$new_boot_number,$boot_order_cur" || { echo "Final boot order change failed"; return 1; }
449+
if [ "$?" -eq 0 ]; then
450+
success "Made Disk as first boot option"
451+
#unmount the partitions
452+
for mount in $(mount | grep '/mnt' | awk '{print $3}' | sort -nr); do
453+
umount "$mount"
454+
done
455+
return 0
464456
else
465-
final_boot_order="$new_boot_number" || { echo "Final boot order change failed"; return 1; }
466-
fi
467-
468-
# Update the boot order using efibootmgr
469-
efibootmgr -o "$final_boot_order" || { echo "Updating the Boot order with new boot entry failed"; return 1; }
470-
471-
#Make UEFI boot as inactive
472-
efibootmgr -b "$usb_boot_number" -A
473-
474-
echo "Made Disk as first boot option"
475-
return 0
457+
failure "Boot entry create failed,Please check!!"
458+
#unmount the partitions
459+
for mount in $(mount | grep '/mnt' | awk '{print $3}' | sort -nr); do
460+
umount "$mount"
461+
done
462+
return 1
463+
fi
476464
}
477465

478466
# Update the MAC address under 99-dhcp.conf file

standalone-node/provisioning_scripts/os-update.sh

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -204,30 +204,28 @@ if [ -f "$INSTALLER_CFG" ]; then
204204
# Use awk to find the end of the runcmd block and append new content
205205
awk -v script="$COMMIT_UPDATE_SCRIPT" '
206206
BEGIN {
207-
line = "bash " script
208-
runcmd = 0
209-
in_block = 0
207+
line = " bash " script
208+
added = 0
210209
}
211-
212210
/^runcmd:/ { runcmd = 1 }
213211
214-
runcmd && /^ - \|/ { in_block = 1 }
215-
{
212+
runcmd && /source \/etc\/environment/ {
216213
print
217-
next_line = $0
214+
print line
215+
added = 1
216+
next
218217
}
219218
220-
in_block && $0 !~ /^ / {
221-
print " " line
222-
in_block = 0
223-
runcmd = 0
219+
{
220+
print
224221
}
225222
226223
END {
227-
if (in_block) {
228-
print " " line
224+
if (!added) {
225+
print line
229226
}
230227
}
228+
231229
' "$INSTALLER_CFG" > "${INSTALLER_CFG}.tmp" && mv "${INSTALLER_CFG}.tmp" "$INSTALLER_CFG"
232230
else
233231
echo "Entry for commit_update.sh already exists in installer.cfg."

0 commit comments

Comments
 (0)