#!/bin/sh
#
# Copyright (C) 2016 Dream Property GmbH
#

source librecovery

compatible dm820 dm7080

usage()
{
	echo "Usage: ${0} [-hqtv] <A|B|C>"
	exit ${1}
}

xgetopts $@
shift $((${OPTIND} - 1))
[ "$#" -eq 1 ] || usage 1
OPTION=${1}

is_writable_blockdev "${FLASH_DEVICE}" || abort "Target block device '${FLASH_DEVICE}' is not a writable block device"
! is_empty "${OPTION}" || abort "No option given"

case "${OPTION}" in
	A|B|C)
		;;
	*)
		abort "Invalid boot option: ${OPTION}"
		;;
esac

select_boot_source "${FLASH_DEVICE}" "${OPTION}" || abort "Failed to enable boot source"
