#! /bin/sh
#
# update-step-7
#
# Tell the bootloader to try the new partition at next boot.
#
# Logilin 2020 - All right reserved.

PARTITION_NAME_FILE="/tmp/partition"
PARTITION_PREFIX="/dev/mmcblk0p"

partition=$(cat "${PARTITION_NAME_FILE}")
new_boot="${partition#${PARTITION_PREFIX}}"

if ! /bin/mount /boot/ -o rw
then
	echo "Unable to mount /boot" >&2
	exit 1
fi
/sbin/fw_setenv boot_next_1 ${new_boot}
/sbin/fw_setenv boot_next_2 ${new_boot}
/sbin/fw_setenv boot_next_3 ${new_boot}
umount /boot/

sleep 1
exit 0
