This script was an attempt from me to use systemd-boot on Fedora Silverblue. I am using it since months now but it has its drawbacks.
It never failed so far on a single “rpm-ostree upgrade” command and afterwards running this script.
But when you install/uninstall rpm packages sometimes there is this change from /ostree/boot.0 to /ostree/boot.1 or vice versa and I have no idea how to predict what it will use after reboot. I put some swap logic into this script but this does not cover all cases.
I raised the question here:
Somebody should explain to me how I can know before reboot whether this number will be 0 and 1. Then I can update my script.
So far I often end up with a black screen and have to go into the BIOS and use grub again and fix this number. Once booted by grub you don’t even have to fix the loader entry manually: you can just run this script and the number will be correct. Once this is done I can use efibootmgr to go back to systemd-boot.
And you are right: this is not a removal of grub. I use both in parallel - grub only as fallback for the situation described above.
Also I have learned that it is not possible to remove the partition layout to a /boot with vfat and no extra efi partion (just normal directory). Fedora Silverblue becomes unusable with this.
As a workaround I make /boot/efi large enough for kernel and initrd (1GB , same as /boot).