#!/bin/bash
# 2.8+ check NGCP type before running ngcp-upgrade
# it should prevent running PRO ngcp-upgrade on CE by mistake

set -e

if dpkg-query -s ngcp-ngcp-pro >/dev/null 2>&1 ; then
  echo "ERROR: ngcp-upgrade CE edition cannot be used for PRO upgrades!" >&2
  echo "Exiting to avoid possible damage." >&2
  exit 1
fi

if dpkg-query -s ngcp-ngcp-carrier >/dev/null 2>&1 ; then
  echo "ERROR: ngcp-upgrade CE edition cannot be used for Carrier upgrades!" >&2
  echo "Exiting to avoid possible damage." >&2
  exit 1
fi

echo "All OK here."
exit 0
