#!/bin/bash

set -eEuo pipefail

die() {
  local message="$*"

  echo "ERROR: ${message}" >&2
  exit 1
}

if [[ "${CURRENT_PARTITION}" == "${TO_PARTITION}" ]]; then
  die "Current root partition and fallback root partition are equal"
fi

if [[ ! -b "${TO_PARTITION}" ]]; then
  die "Fallback partition '${TO_PARTITION}' is not a block device"
fi
