apiVersion: v1
kind: ConfigMap
metadata:
  name: entitlement-tester-entrypoint
  namespace: default
data:
  entrypoint.sh: |-
    #!/bin/bash
    set -o errexit;
    set -o pipefail;
    set -x

    echo "# Kernel version"
    uname -a
    echo

    echo "# Host OS Release"
    cat /etc-host/os-release
    source /etc-host/os-release
    echo

    echo "# md5sum of entitlement file (debug)"
    if md5sum /etc/rhsm-host/rhsm.conf /etc/pki/entitlement-host/entitlement{,-key}.pem; then
      echo "# INFO: entitlement files found"
    else
      echo "#"
      echo "# WARNING: entitlement files missing"
      echo "#"
    fi
    echo

    echo "# test EUS and OCP repositories (debug)"

    echo "${RHEL_VERSION}" > /etc/yum/vars/releasever
    for repo in rhocp-${OPENSHIFT_VERSION}-for-rhel-8-x86_64-rpms rhel-8-for-x86_64-baseos-eus-rpms; do
      if dnf config-manager --set-enabled $repo; then
        if dnf makecache; then
          echo "# INFO: repo '$repo' can be enabled"
        else
          echo "#"
          echo "# WARNING: failed to cache repo '$repo'"
          echo "#"
        fi
        dnf config-manager --set-disabled $repo
      else
        echo "#"
        echo "# WARNING: failed to enable repo '$repo'"
        echo "#"
      fi
    done

    echo
    echo "# ensure that RH repositories can be accessed"

    dnf list kernel-core --showduplicates
