#!/bin/sh

# This is run by systemd from the sx_sdk unit file.

# check and update firmware if needed
if /usr/bin/platform-detect | grep -q 'msn4800'; then
	rm -rf /dev/mst/mt6518_pciconf*
fi

# On Palladium we do not want to run mlxfwupgrade.sx
if /usr/bin/platform-detect | grep -q 'pld_sn5600'; then
        echo "mlxfwupgrade.sx skipped!"
else
	/usr/lib/cumulus/mlxfwupgrade.sx
	sleep 10
fi

#Drivers are always reloaded to force firmware reset
cd /usr/lib/cumulus/ && \
PATH="$PATH:/usr/lib/cumulus/" /usr/lib/cumulus/sxdkernel start

exec /usr/bin/sx_sdk --syslog
