#!/bin/sh

. /usr/local/bin/sig_catcher

force_read=$1

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
	if [ "$force_read" != "-f" ]; then
		if [ -f /var/run/switch_version_controller ]; then
			cat /var/run/switch_version_controller
			exit 0
		fi
	fi
	ep_version=$(/usr/local/bin/switch ep_version)
	echo "$ep_version" > /var/run/switch_version_controller
	echo "$ep_version"
else
	echo "Command not supported on this platform"
fi

exit 0

