Debian Codegraph @

launcher/image/fixup_oem.sh

raw
1 #!/bin/bash
2
3 main() {
4 if [[ ! -d /mnt/disks/efi ]]; then
5 mkdir /mnt/disks/efi
6 fi
7 mount /dev/sda12 /mnt/disks/efi
8 sed -i -e 's|systemd.mask=usr-share-oem.mount||g' /mnt/disks/efi/efi/boot/grub.cfg
9
10 # TODO: Remove this fix once the upstream customizer fixed the bug.
11 # Fix a string manipulation bug in the dm part of the kernel cmd.
12 if grep -q "dm-m2d" /mnt/disks/efi/efi/boot/grub.cfg; then
13 sed -i -e 's|dm-m2d|dm-mod|g' /mnt/disks/efi/efi/boot/grub.cfg
14 sed -i -e 's|,oemroot|;oemroot|g' /mnt/disks/efi/efi/boot/grub.cfg
15 fi
16
17 # Print grub.cfg's kernel command line.
18 grep -i '^\s*linux' /mnt/disks/efi/efi/boot/grub.cfg | \
19 sed -e 's|.*|[BEGIN_CS_GRUB_CMDLINE]&[END_CS_GRUB_CMDLINE]|g'
20
21 # Convert grub.cfg's kernel command line into what GRUB passes to the kernel.
22 grep -i '^\s*linux' /mnt/disks/efi/efi/boot/grub.cfg | \
23 sed -e "s|'ds=nocloud;s=/usr/share/oem/'|ds=nocloud;s=/usr/share/oem/|g" | \
24 sed -e 's|\\"|"|g' | \
25 sed -e 's|dm-mod.create="|"dm-mod.create=|g' | \
26 sed -e 's|.*|[BEGIN_CS_CMDLINE]&[END_CS_CMDLINE]|g'
27
28 umount /mnt/disks/efi
29
30 # Now the oem partition is sealed, we mount it to print it's content
31 if [[ ! -d /mnt/disks/oem ]]; then
32 mkdir /mnt/disks/oem
33 fi
34
35 # Since it's sealed, we mount it read-only to prevent changes
36 mount -o ro /dev/sda8 /mnt/disks/oem
37
38 ls -l /mnt/disks/oem/
39 ls -l /mnt/disks/oem/confidential_space
40
41 umount /mnt/disks/oem
42 }
43
44 main