set default=99 set timeout=1 set ORDER="A B" set A_OK=0 set B_OK=0 set A_TRY=0 set B_TRY=0 set MACHINE_ID="" load_env # select bootable slot for SLOT in $ORDER; do if [ "$SLOT" == "A" ]; then INDEX=0 OK=$A_OK TRY=$A_TRY A_TRY=1 fi if [ "$SLOT" == "B" ]; then INDEX=1 OK=$B_OK TRY=$B_TRY B_TRY=1 fi if [ "$OK" -eq 1 -a "$TRY" -eq 0 ]; then default=$INDEX break fi done # reset booted flags if [ "$default" -eq 99 ]; then if [ "$A_OK" -eq 1 -a "$A_TRY" -eq 1 ]; then A_TRY=0 fi if [ "$B_OK" -eq 1 -a "$B_TRY" -eq 1 ]; then B_TRY=0 fi default=0 fi save_env A_TRY A_OK B_TRY B_OK ORDER MACHINE_ID default_cmdline="rootwait zram.enabled=1 zram.num_devices=3 apparmor=1 security=apparmor systemd.machine_id=$MACHINE_ID cgroup_enable=memory fsck.repair=yes" file_env -f ($root)/cmdline.txt cmdline # root is a full HDD/partition definition in GRUB format like hd0,gpt1 # We extract the part before the comma to then append our own partition index # at the end. This is hacky but the best way I found regexp --set 1:boothd (.+),.+ ${root} menuentry "Slot A (OK=$A_OK TRY=$A_TRY)" { linux (${boothd},gpt2)/bzImage root=PARTUUID=8d3d53e3-6d49-4c38-8349-aff6859e82fd $default_cmdline $cmdline rauc.slot=A } menuentry "Slot B (OK=$B_OK TRY=$B_TRY)" { linux (${boothd},gpt4)/bzImage root=PARTUUID=a3ec664e-32ce-4665-95ea-7ae90ce9aa20 $default_cmdline $cmdline rauc.slot=B }