#!/bin/bash

# Automatically regenerate the NSX text configs, load them onto a switch, and
# retrieve the matching binary configurations.

set -euo pipefail

SWITCH_IP=$1
TFTP_IP=$2

vehicle/network/config/generate_c3_6_configs --time_source EMU
vehicle/network/config/load_nova_config --time_source EMU /dev/ttyUSB0
vehicle/network/config/nova_deploy --fetch --time_source EMU "$SWITCH_IP" "$TFTP_IP"
vehicle/network/config/generate_c3_6_configs --time_source GPS
vehicle/network/config/load_nova_config --time_source GPS /dev/ttyUSB0
vehicle/network/config/nova_deploy --fetch --time_source GPS "$SWITCH_IP" "$TFTP_IP"

