#!/bin/sh

. /usr/local/bin/sig_catcher

usage() {
    echo "No parameters needed."
    exit 1
}

if [ $# -gt 0 ]; then
    usage
fi

platform=$(cat /var/run/platform)
brdrev=$(cat /var/run/boardrev)
lml_rev_p2i=2

if [ "$platform" == "Lodi" ] || [ "$platform" == "Madera" ] || [ "$platform" == "Livermore" ] ; then
	if [ "$brdrev" -lt "$lml_rev_p2i" ] ; then
		echo "Command not supported on $brdrev boardrev of this platform"
		exit 1
	fi
	switch_file=$(ls /firmware/$platform/switch/controller_switch_img.bin)
	if [ -f "$switch_file" ]; then
		/usr/local/bin/switch ep_verify < "$switch_file"
		echo ""
	else
		echo "$switch_file cannot be found."
		exit 1
	fi
fi

exit 0

