#!/bin/bash -ex

function cleanup() {
    rm -f "/etc/cni/net.d/10-kuryr.conflist"
    rm -f "/opt/cni/bin/kuryr-cni"
}

function deploy() {
    # Copy the binary into the designated location
    cp /kuryr-cni "/opt/cni/bin/kuryr-cni"
    chmod +x /opt/cni/bin/kuryr-cni
    cp /etc/kuryr-cni/10-kuryr.conflist /etc/cni/net.d/10-kuryr.conflist
}

cleanup
deploy

exec kuryr-daemon --config-file /etc/kuryr/kuryr.conf
