update to 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 /bullseye_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=/debianbullseye_bootstrap # could use 0 here.
29 set timeout=1
30
31 # grub_extn
32 for part in (ahci*7) (ata*7); do
33 envfile=$part/grubenv
34 if [ -s $envfile ]; then
35 load_env --file $envfile
36 if [ x$did_fai_check == xfalse -a x$last_boot != x$default ]; then
37 set default=fai-check
38 elif [ ! -z $last_boot ]; then
39 set default=$last_boot
40 fi
41 break
42 fi
43 done
44
45 did_fai_check=false
46
47 bs_dir=/debianbullseye_bootstrap
48 menuentry $bs_dir --id=$bs_dir {
49 # note, we might be able to use $chosen and avoid setting this here,
50 # and set it inside save_chosen. but I haven't tested it,
51 # it's just one less line of repitition.
52 last_boot=$1
53 save_chosen
54 configfile $bs_dir/boot/grub/grub.cfg
55 }
56
57 for dir in /boot_*; do
58 if [ $dir == '/boot_*' ]; then
59 break
60 fi
61 menuentry $dir --id=$dir {
62 last_boot=$1
63 save_chosen
64 configfile $1/grub/grub.cfg
65 }
66 done
67
68 menuentry fai-check --id=fai-check {
69 did_fai_check=true
70 save_vars did_fai_check
71 configfile $bs_dir/boot/grub/grub.cfg
72 }