Skip to content

Commit 098fc93

Browse files
committed
Fix regression introduced in 547cb93
Signed-off-by: David Cassany <dcassany@suse.com>
1 parent 547cb93 commit 098fc93

1 file changed

Lines changed: 31 additions & 23 deletions

File tree

pkg/features/embedded/cloud-config-essentials/system/oem/08_boot_assessment.yaml

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,14 @@ stages:
1616
# enable_boot_assessment to 'yes'.
1717
# This can be then customized easily by having a cloud-config file which always enables boot assessment on
1818
# the boot stage.
19-
- &remountEFIrw
20-
name: "Mounting EFI as RW"
21-
if: 'mountpoint -q /run/elemental/efi'
22-
commands:
23-
- mount -o rw,remount /run/elemental/efi
2419
- name: "Remove GRUB sentinels"
2520
if: '[ -f "/run/elemental/active_mode" ]'
2621
commands:
2722
- |
23+
mount -o rw,remount /run/elemental/efi
2824
grub2-editenv /run/elemental/efi/boot_assessment set enable_boot_assessment=
2925
grub2-editenv /run/elemental/efi/boot_assessment set boot_assessment_tentative=
30-
- &remountEFIro
31-
name: "Mounting EFI as RO"
32-
if: 'mountpoint -q /run/elemental/efi'
33-
commands:
34-
- mount -o ro,remount /run/elemental/efi
26+
mount -o ro,remount /run/elemental/efi
3527
- name: "Create upgrade failure sentinel if necessary"
3628
if: cat /proc/cmdline | grep -q "upgrade_failure"
3729
files:
@@ -40,24 +32,40 @@ stages:
4032
permissions: 0600
4133
owner: 0
4234
group: 0
35+
4336
after-install:
4437
# After install, reset, and upgrade, we install additional GRUB configuration for boot assessment into COS_GRUB.
4538

39+
# Note we mount efi partition in a new location in order workaround potentially different
40+
# mountpoints across install, reset and upgrade commands.
41+
4642
# Here we hook the boot assessment configuration to 'grubcustom'
4743
# we do that selectively in order to just "append" eventual other configuration provided.
48-
# XXX: maybe we should just write to /grubcustom and override any other custom grub?
44+
- &efimount
45+
name: "Mount efi"
46+
commands:
47+
- |
48+
EFIDIR=/tmp/mnt/EFI
49+
EFI=$(blkid --list-one --output device --match-token PARTLABEL=efi || true)
50+
mkdir -p $EFIDIR || true
51+
mount ${EFI} $EFIDIR
4952
- &customhook
5053
name: "Hook boot assessment grub configuration"
51-
if: '[ ! -f "/run/elemental/efi/grubcustom" ]'
54+
if: '[ ! -f "/tmp/mnt/EFI/grubcustom" ]'
5255
files:
53-
- path: "/run/elemental/efi/grubcustom"
56+
- path: "/tmp/mnt/EFI/grubcustom"
5457
permissions: 0600
5558
content: |
5659
set bootfile="/grub_boot_assessment"
5760
search --no-floppy --file --set=bootfile_loc "${bootfile}"
5861
if [ "${bootfile_loc}" ]; then
5962
source "(${bootfile_loc})${bootfile}"
6063
fi
64+
- &efiumount
65+
name: "Mount efi"
66+
commands:
67+
- |
68+
umount /tmp/mnt/EFI
6169
6270
# Overrides the active cmdline by adding "rd.emergency=reboot", "rd.shell=0" and "panic=5"
6371
# so that any failure in booting initramfs or kernel loading results in a reboot.
@@ -69,9 +77,9 @@ stages:
6977
#
7078
- &bootgrub
7179
name: "Add boot assessment grub configuration"
72-
if: '[ ! -f "/run/elemental/efi/grub_boot_assessment" ]'
80+
if: '[ ! -f "/tmp/mnt/EFI/grub_boot_assessment" ]'
7381
files:
74-
- path: "/run/elemental/efi/grub_boot_assessment"
82+
- path: "/tmp/mnt/EFI/grub_boot_assessment"
7583
owner: 0
7684
group: 0
7785
permissions: 0600
@@ -96,28 +104,28 @@ stages:
96104
# Here we do enable boot assessment for the next bootup.
97105
# Similarly, we could trigger boot assessment in other cases
98106
after-upgrade:
99-
- <<: *remountEFIrw
107+
- <<: *efimount
100108
- name: "Set upgrade sentinel on active"
101109
if: '[ ! -f "/run/elemental/recovery_mode" ]'
102110
commands:
103-
- grub2-editenv /run/elemental/efi/boot_assessment set enable_boot_assessment=yes
111+
- grub2-editenv /tmp/mnt/EFI/boot_assessment set enable_boot_assessment=yes
104112
- name: "Set upgrade sentinel on recovery"
105113
if: '[ -f "/run/elemental/recovery_mode" ]'
106114
commands:
107-
- grub2-editenv /run/elemental/efi/boot_assessment set enable_boot_assessment=yes
115+
- grub2-editenv /tmp/mnt/EFI/boot_assessment set enable_boot_assessment=yes
108116
# We do re-install hooks here if needed to track upgrades of boot assessment
109117
- <<: *customhook
110118
- <<: *bootgrub
111-
- <<: *remountEFIro
119+
- <<: *efiumount
112120

113121
after-reset:
114-
- <<: *remountEFIrw
122+
- <<: *efimount
115123
- name: "Remove GRUB sentinels"
116124
commands:
117125
- |
118-
grub2-editenv /run/elemental/efi/boot_assessment set enable_boot_assessment=
119-
grub2-editenv /run/elemental/efi/boot_assessment set boot_assessment_tentative=
126+
grub2-editenv /tmp/mnt/EFI/boot_assessment set enable_boot_assessment=
127+
grub2-editenv /tmp/mnt/EFI/boot_assessment set boot_assessment_tentative=
120128
# Reset completely restores COS_STATE, so we re-inject ourselves
121129
- <<: *customhook
122130
- <<: *bootgrub
123-
- <<: *remountEFIro
131+
- <<: *efiumount

0 commit comments

Comments
 (0)