#!/usr/bin/env bash

set -euo pipefail

# Todo: check version and continue installation only for a newer version

# Install Antrea configuration file
install -m 644 /etc/antrea/antrea-cni.conflist /host/etc/cni/net.d/10-antrea.conflist

# Install Antrea binary file
install -m 755 /usr/local/bin/antrea-cni /host/opt/cni/bin/antrea

# Install the loopback plugin.
# It is required by kubelet on Linux when using docker as the container runtime.
# We replace the binary files even they are already present on the Node to make
# sure expected versions are used.
install -m 755 /opt/cni/bin/loopback /host/opt/cni/bin/loopback

# Install PortMap CNI binary file. It is required to support hostPort.
install -m 755 /opt/cni/bin/portmap /host/opt/cni/bin/portmap

# Install bandwidth CNI binary file, It is required to support traffic shaping.
install -m 755 /opt/cni/bin/bandwidth /host/opt/cni/bin/bandwidth
