changes for bullseye
[automated-distro-installer] / fai / config / distro-install-common / libreboot_grub.cfg
1 #!/bin/sh
2 # shebang is for editor file mode detection only
3
4 function save_vars {
5 if [ -s $envfile ]; then
6 for var in $@; do
7 save_env --file $envfile $var
8 done
9 fi
10 }
11
12 function save_chosen {
13 save_vars did_fai_check last_boot
14 }
15
16 # fai_check is so we can act like a pxe boot, but just for fai, and by
17 # using /stretch_bootstrap to do it. We toggle on and off the grub var
18 # did_fai_check so we can do the check every other boot. Then
19 # /debian_bootstrap checks for that var on boot and if we want to do a
20 # fai check, it does it, then reboots. But fai-check also sets
21 # did_fai_check to a 3rd state os_true which means we did the fai check,
22 # and we don't want to do it again. This is useful for systems without
23 # libreboot, although it's not used yet.
24
25 # We don't set this to fai check so we can't get into
26 # an infinite reboot cycle. We depend on the os to
27 # create the initial grubenv file.
28 set default=/debianbuster_bootstrap # could use 0 here.
29 set timeout=1
30
31 for part in (ahci*4) (ata*4); do
32 envfile=$part/grubenv
33 if [ -s $envfile ]; then
34 load_env --file $envfile
35 if [ x$did_fai_check == xfalse -a x$last_boot != x$default ]; then
36 set default=fai-check
37 elif [ ! -z $last_boot ]; then
38 set default=$last_boot
39 fi
40 break
41 fi
42 done
43
44 did_fai_check=false
45
46 bs_dir=/debianbuster_bootstrap
47 menuentry $bs_dir --id=$bs_dir {
48 # note, we might be able to use $chosen and avoid setting this here,
49 # and set it inside save_chosen. but I haven't tested it,
50 # it's just one less line of repitition.
51 last_boot=$1
52 save_chosen
53 configfile $bs_dir/boot/grub/grub.cfg
54 }
55
56 for dir in /boot_*; do
57 if [ $dir == '/boot_*' ]; then
58 break
59 fi
60 menuentry $dir --id=$dir {
61 last_boot=$1
62 save_chosen
63 configfile $1/grub/grub.cfg
64 }
65 done
66
67 menuentry fai-check --id=fai-check {
68 did_fai_check=true
69 save_vars did_fai_check
70 configfile $bs_dir/boot/grub/grub.cfg
71 }