#!/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

	/usr/local/bin/switch reset
	ret=$?

	if [ $ret -eq 0 ] ; then
		echo "Controller Switch has been reset."
	else
		echo "ERROR: Controller Switch reset failed."
	fi
fi

exit 0
