--- apiVersion: v1 items: - apiVersion: v1 data: cnibincopy.sh: |- #!/bin/bash DESTINATION_DIRECTORY=/host/opt/cni/bin/ # Perform validation of usage if [ -z "$RHEL7_SOURCE_DIRECTORY" ] || [ -z "$RHEL8_SOURCE_DIRECTORY" ] || [ -z "$DEFAULT_SOURCE_DIRECTORY" ]; then echo "FATAL ERROR: You must set env variables: RHEL7_SOURCE_DIRECTORY, RHEL8_SOURCE_DIRECTORY, DEFAULT_SOURCE_DIRECTORY" exit 1 fi if [ ! -d "$DESTINATION_DIRECTORY" ]; then echo "FATAL ERROR: Destination directory ($DESTINATION_DIRECTORY) does not exist" exit 1 fi # Collect host OS information . /host/etc/os-release rhelmajor= # detect which version we're using in order to copy the proper binaries case "${ID}" in rhcos) rhelmajor=8 ;; rhel) rhelmajor=$(echo "${VERSION_ID}" | cut -f 1 -d .) ;; fedora) if [ "${VARIANT_ID}" == "coreos" ]; then rhelmajor=8 else echo "FATAL ERROR: Unsupported Fedora variant=${VARIANT_ID}" exit 1 fi ;; *) echo "FATAL ERROR: Unsupported OS ID=${ID}"; exit 1 ;; esac # Set which directory we'll copy from, detect if it exists sourcedir= founddir=false case "${rhelmajor}" in 7) if [ -d "${RHEL7_SOURCE_DIRECTORY}" ]; then sourcedir=${RHEL7_SOURCE_DIRECTORY} founddir=true fi ;; 8) if [ -d "${RHEL8_SOURCE_DIRECTORY}" ]; then sourcedir=${RHEL8_SOURCE_DIRECTORY} founddir=true fi ;; *) echo "ERROR: RHEL Major Version Unsupported, rhelmajor=${rhelmajor}" ;; esac # When it doesn't exist, fall back to the original directory. if [ "$founddir" == false ]; then echo "Source directory unavailable for OS version: ${rhelmajor}" sourcedir=$DEFAULT_SOURCE_DIRECTORY fi cp -rf ${sourcedir}* $DESTINATION_DIRECTORY if [ $? -eq 0 ]; then echo "Successfully copied files in ${sourcedir} to $DESTINATION_DIRECTORY" else echo "Failed to copy files in ${sourcedir} to $DESTINATION_DIRECTORY" exit 1 fi kind: ConfigMap metadata: annotations: kubernetes.io/description: | This is a script used to copy CNI binaries based on host OS release.openshift.io/version: 0.0.1-2020-05-26-050349 creationTimestamp: "2020-05-26T09:37:39Z" managedFields: - apiVersion: v1 fieldsType: FieldsV1 fieldsV1: f:data: .: {} f:cnibincopy.sh: {} f:metadata: f:annotations: .: {} f:kubernetes.io/description: {} f:release.openshift.io/version: {} f:ownerReferences: .: {} k:{"uid":"01eb3f97-b2fe-46bc-bfa8-0f197fc5144c"}: .: {} f:apiVersion: {} f:blockOwnerDeletion: {} f:controller: {} f:kind: {} f:name: {} f:uid: {} manager: cluster-network-operator operation: Update time: "2020-05-26T09:37:39Z" name: cni-binary-copy-script namespace: openshift-multus ownerReferences: - apiVersion: operator.openshift.io/v1 blockOwnerDeletion: true controller: true kind: Network name: cluster uid: 01eb3f97-b2fe-46bc-bfa8-0f197fc5144c resourceVersion: "2187" selfLink: /api/v1/namespaces/openshift-multus/configmaps/cni-binary-copy-script uid: 74f7ce62-48ae-457d-9409-51cbcddf59b6 kind: ConfigMapList metadata: resourceVersion: "56476" selfLink: /api/v1/namespaces/openshift-multus/configmaps