#!/bin/bash

set -eEuo pipefail

echo "Checking if the current partition is ${UPGRADE_VERSION}"

cur_version=$(cat /etc/ngcp_version)

if [[ "${cur_version}" == "${UPGRADE_VERSION}" ]]; then
  echo "OK: the current partition is ${UPGRADE_VERSION}, continue the upgrade"
else
  echo "ERROR: the current version is not equal to target one ${UPGRADE_VERSION}" >&2
  echo "Most probably you've forgot to run /usr/share/ngcp-upgrade/ngcp-switch-root-partition before the reboot" >&2
  echo "Do it now and continue the upgrade" >&2
  exit 1
fi
