#!/usr/bin/env bash

MAIN_AI_MAC="ac:1f:6b:a1:d2:82"
VISION_MAC="ac:1f:6b:a1:d2:31"
IPMI_PASSWORD="newboschpassword"

MAIN_AI_IP=$(ip neighbor | grep -v STALE | grep "${MAIN_AI_MAC}" | cut -d" " -f1)
VISION_IP=$(ip neighbor | grep -v STALE | grep "${VISION_MAC}" | cut -d" " -f1)

if [ ! -z "${MAIN_AI_IP}" ] ; then
    echo "Detected main-ai at ${MAIN_AI_IP}. Commanding power on..."
    ipmitool -I lanplus -H "${MAIN_AI_IP}" -U ADMIN -P "${IPMI_PASSWORD}" chassis power on
else
    echo "main-ai not detected."
fi

if [ ! -z "${VISION_IP}" ] ; then
    echo "Detected vision at ${VISION_IP}. Commanding power on..."
    ipmitool -I lanplus -H "${VISION_IP}" -U ADMIN -P "${IPMI_PASSWORD}" chassis power on
else
    echo "vision not detected."
fi

