#!/bin/bash

# Follow these steps to run pmav loader as a cronjob on your desktop
# 1. Make sure ssh-agent is running. You can add lines 12-18 in your .bashrc for this.
# 2. Copy the script you are looking at to ~/pmav_loader.sh.
# 3. Add this to crontab by running `crontab -e` and then pasting the line.
# */10 * * * * cd <PATH_TO_DRIVING_REPO> && bash ~/pmav_loader.sh > ~/pmav_loader.log 2>&1

set -euo pipefail
set -x

if [ ! -S ~/.ssh/ssh_auth_sock ]; then
    eval `ssh-agent`
    ln -sf "$SSH_AUTH_SOCK" ~/.ssh/ssh_auth_sock
fi

export SSH_AUTH_SOCK=~/.ssh/ssh_auth_sock
ssh-add -l > /dev/null || ssh-add

# Keep adding new metrics as params to collect:load
git checkout master && bazel run //vehicle/planner/metrics/pmav:load -- --slac_sim --planner_simtest --logbot --planner_latency --pcp_latency --stuck --ped_proximity --ntlj --cw_safety --statics --follow --paranoia --jw_safety --slac_planner_simtest --cas --criticals > /home/anavindgi/logs/loader/$(date +%m-%d-%y_%H:%M).log
