#!/bin/sh

echo "Copy magma_mic_server to MIC cards..."
PATH="./interface_mic/server/magma_mic_server"
NCard=4

if [ $# -eq 0 ] ; then
	echo "Usage: $0 Number_of_MIC_cards  Path_to_magma_mic_server_file"
elif [ $# -eq 1 ] ; then
	NCard=$1
elif [ $# -eq 2 ]; then
	NCard=$1
	PATH=$2
else
	echo "Usage: $0 Number_of_MIC_cards  Path_to_magma_mic_server_file"
	exit 0
fi

echo "Number of mic card: $NCard"
echo "Server file: $PATH"

for (( i = 0; i < $NCard; i++ ))
do
	MIC_PATH="root@mic$i:/tmp"
	/usr/bin/scp -i /mnt/scratch/id_rsa $PATH     $MIC_PATH
	/usr/bin/scp -i /mnt/scratch/id_rsa launch.sh $MIC_PATH
done
