#!/bin/bash mlxconfig_enable_pxe() { SYSPATH="/sys/class/infiniband/" # mlxconfig operates on interface names for dev in $(ls ${SYSPATH}); do echo "Enabling PXE on ${dev}" mlxconfig -y -d ${dev} set EXP_ROM_PXE_ENABLE=1 echo "Enabling UEFI on ${dev}" mlxconfig -y -d ${dev} set EXP_ROM_UEFI_x86_ENABLE=1 done } mstconfig_enable_pxe() { SYS_BUS_PATH="/sys/bus/pci/devices" # mstconfig operates on BDFs for bdf in $(ls "${SYS_BUS_PATH}"); do if [[ -e "${SYS_BUS_PATH}/${bdf}/infiniband" ]]; then echo "Enabling PXE on ${bdf}" mstconfig -y -d "${bdf}" set EXP_ROM_PXE_ENABLE=1 echo "Enabling UEFI_x86 on ${dev}" mstconfig -y -d "${bdf}" set EXP_ROM_UEFI_x86_ENABLE=1 echo "Enabling UEFI_ARM on ${dev}" mstconfig -y -d "${bdf}" set EXP_ROM_UEFI_ARM_ENABLE=1 fi done } mlnx_enable_pxe() { if which mlxconfig; then mlxconfig_enable_pxe elif which mstconfig; then mstconfig_enable_pxe fi } ipmi_set_boot() { echo "Changing boot order to network first" ipmitool raw 0x00 0x08 0x05 0xe0 0x08 0x00 0x00 0x00 && ipmitool chassis bootdev pxe options=efiboot } check_bins() { NO_MLXCONFIG="false" NO_MSTCONFIG="false" which mlxconfig > /dev/null 2>&1 if [ $? -ne 0 ]; then NO_MLXCONFIG="true" fi which mstconfig > /dev/null 2>&1 if [ $? -ne 0 ]; then NO_MSTCONFIG="true" fi if [[ "${NO_MLXCONFIG}" = "true" ]] && \ [[ "${NO_MSTCONFIG}" = "true" ]]; then echo "Could not locate mlxconfig or mstconfig on system" exit 1 fi which ipmitool > /dev/null 2>&1 if [ $? -ne 0 ]; then echo "Could not locate ipmitool on system" exit 1 fi } do_reboot=0 if [[ $EUID -ne 0 ]]; then echo "This script must be run as root" exit 1 fi while getopts ":r" opt; do case ${opt} in r ) do_reboot=1 ;; \? ) echo "Usage: mlnx_pxe_setup.bash [-r]" exit 0 ;; esac done check_bins mlnx_enable_pxe #ipmi_set_boot