#!/bin/bash

set -euo pipefail

if [ "$#" -ne 1 ]; then
    echo "Please provide the time source"
    echo "  Usage: loadall_tftp.sh <EMU, GPS>"
    exit 1
fi

function cleanup() {
  rm "$runcmd"
}

runcmd="$(mktemp /tmp/bazel-run.XXXXXX)" || die "Could not create temporary file"
trap cleanup EXIT

bazel run --script_path="$runcmd" //vehicle/network/config:nova_deploy

"$runcmd" 192.168.7.70 192.168.7.1 --load --upgrade --time_source $1
"$runcmd" 192.168.6.71 192.168.6.1 --load --upgrade --time_source $1
"$runcmd" 192.168.7.72 192.168.7.1 --load --upgrade --time_source $1
"$runcmd" 192.168.6.73 192.168.6.1 --load --upgrade --time_source $1
