#!/bin/sh

set -e

ME=$(basename $0)

usage () {
	echo "$0: copy boot files needed to boot arm64 into the destination PXE server."
	echo "usage: $ME <destination-host>"
	exit 1
}

if [ -z "${1}" ] ; then
	usage
fi

if ! [ -e binary/live/filesystem.squashfs ] ; then
	echo "Cannot find binary/live/filesystem.squashfs."
	echo "$ME must be started from where you built the OCI live image."
fi

# Note: this only works for arm64, we may add more code to handle other arch here...

scp binary/live/filesystem.squashfs root@${1}:/var/lib/openstack-cluster-installer/filesystem_arm64.squashfs
scp tftpboot/live/initrd* root@${1}:/var/lib/openstack-cluster-installer/tftp/live/initrd-arm64.img
scp tftpboot/live/vmlinuz* root@${1}:/var/lib/openstack-cluster-installer/tftp/live/vmlinuz-arm64
scp /usr/lib/shim/shimaa64.efi.signed root@${1}:/var/lib/openstack-cluster-installer/tftp/shimaa64.efi.signed
scp /usr/lib/grub/arm64-efi-signed/grubnetaa64.efi.signed root@${1}:/var/lib/openstack-cluster-installer/tftp/
