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

source librecovery

usage()
{
	echo "Usage: ${0} [-hqtv] <vmlinuz-rescue.bin>"
	exit ${1}
}

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

! is_empty "${FILENAME}" || abort "No rescue image given"
is_readable_file "${FILENAME}" || abort "Cannot access '${FILENAME}'"
writespi ${FILENAME} kernel || abort "Failed to write rescue image"
