#!/bin/bash
# Install Mellanox MFT, & mstflint Tools
# Change Adapters to ETHERNET
# wget -4 -O - mirror.enzu.com/software/mellanox/mft.sh | bash
sudo sed -i 's/127.0.0.53/1.1.1.1/g' /etc/resolv.conf;
sudo apt update;
sudo apt install -y gcc;
sudo apt install -y make;
sudo apt install -y dkms;
sudo apt install -y unzip;
sudo apt install -y mstflint;
wget -4 -O ~/mft-4.27.0-83-x86_64-deb.tar http://mirror.enzu.com/software/mellanox/tools/mft-4.27.0-83-x86_64-deb.tar;
tar -xvf ~/mft-4.27.0-83-x86_64-deb.tar;
sudo ~/mft-4.27.0-83-x86_64-deb/install.sh;
sudo mst start;


for card in $(sudo mst status | grep mst | awk '{print $1}'); do 
  sudo mlxconfig -y -d ${card} set LINK_TYPE_P1=2 LINK_TYPE_P2=2; 
done

echo "# ConnectX4LX - Super_Micro_AOC-MH25G-m2S2T - will error - this is ok to proceed";
echo "# Error: -E- The Device doesn't support LINK_TYPE_P1 parameter";