#!/bin/sh

macfile=/scripts/mac_id.ini

# make sure we have the required number of args
if [ "$#" -lt 2 ]
then
echo "Usage: setmac unlock_code aa:bb:cc"
echo "            where aa:bb:cc are last 6 digits of mac address"
fi

# check unlock code
if [ "$1" -eq 2749 ]
then
	b=$2
	length=${#b}
	if [ "$length" -eq 8 ]; then
		/scripts/read-write.sh
		chmod +w $macfile
		exec $(echo EP93XX_MAC=00:50:DB:$2 > $macfile)
		chmod -w $macfile
		/scripts/read-only.sh
	else
		echo invalid mac input
	fi
else
	echo invalid unlock code
fi

exit 0
