#!/bin/sh

# NOTE: this script doesn't handle actual "Packed OTA" format (as on Mini 1),
# It just renames file passed by Quasar to name expected by swupdate inside
# the recovery. 

# Keep this in sync with S01swupdate
OTA_FILE_NAME="yandex_io_ota.swu"

if [ $# -lt 2 ]; then
  echo "Usage: $0 OTAFILE /bkupgrade/ota"
  exit 1
fi

if [ ! -e "${1}" ]; then
  echo "File ${1} does not exist."
  exit 1
fi

mkdir -p ${2}/
mv "${1}" "${2}/${OTA_FILE_NAME}"

fw_setenv boot_to_recovery 1
reboot
