-
Notifications
You must be signed in to change notification settings - Fork 8
/
build_image.sh
61 lines (54 loc) · 1.5 KB
/
build_image.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
script=${BASH_SOURCE[0]}
if [ $script == $0 ]; then
echo "ERROR: You must source this script"
exit 2
fi
if [ "$BUCKET_ID" -eq "" ]; then
echo "ERROR: BUCKET_ID must be set."
fi
full_script=$(readlink -f $script)
script_name=$(basename $full_script)
function usage {
echo -e "USAGE: source $script_name [-d|-dcp DCP_FILE.tar] [-h|-help]"
}
function help {
info_msg "$script_name"
info_msg " "
info_msg "build an FPGA image for POC"
info_msg " "
info_msg "build_agfi.sh script will:"
info_msg " (1) configure aws key and region (us-east-1)"
info_msg " (2) copy the tar file into an existing s3 bucket (in that region)"
info_msg " (3) create an FGPA image and return the corresponding AFI/AGFI identifier for loading it"
echo " "
usage
}
# Process command line args
args=( "$@" )
for (( i = 0; i < ${#args[@]}; i++ )); do
arg=${args[$i]}
case $arg in
-d|-dcp)
tar_file=${args[$i+1]}
i=$i+1
;;
-h|-help)
help
return 0
;;
*)
err_msg "Invalid option: $arg\n"
usage
return 1
esac
done
info_msg " "
info_msg "copying tar file $tar_file to bucket s3://$BUCKET_ID/$tar_file"
aws s3 cp $tar_file s3://$BUCKET_ID/$tar_file
info_msg " "
info_msg "creating afi, logs will be saved in s3://$BUCKET_ID/logs.txt"
aws ec2 create-fpga-image \
--name zprize_msm_submission \
--description "Submission for ZPRIZE" \
--input-storage-location Bucket=$BUCKET_ID,Key=$tar_file \
--logs-storage-location Bucket=$BUCKET_ID,Key=logs.txt > image-id.json