#!/bin/bash
# mr5.5: separate 'check' stage for ngcp-upgrade (TT#21601)
# mr9.5: stop if it's ngcp-upgrade-pre-check (TT#143800)

set -eEuo pipefail

### Mandatory environment variables
: "${OLD_VERSION?ERROR: Missing mandatory environment variable 'OLD_VERSION', cannot continue.}"
: "${UPGRADE_VERSION?ERROR: Missing mandatory environment variable 'UPGRADE_VERSION', cannot continue.}"

echo "Checking for upgrade from '${OLD_VERSION}' to '${UPGRADE_VERSION}' finished successfully on $(date)"

if [[ "${NGCP_UPGRADE_NAME:-}" =~ ^ngcp-upgrade-pre-checks$ ]]; then
  echo "This is ${NGCP_UPGRADE_NAME} and all checks passed, so exiting..."
  exit 0
fi
