#!/bin/sh

script_path=`echo $0 | awk -F '/' '{for(i=2;i<NF;i++) printf"/"$i}'`
echo $script_path

ProductionTestMode=`cat $script_path/productionTestMode.ini | ./busybox grep "productionTestMode:" | ./busybox grep -v grep | sed 's/productionTestMode://g' | sed 's/\r//g' | sed 's/\n//g' | sed "s/$(echo -e '\015')//g"`

if [ $? != 0 ]; then
	echo "cann't found productionTestMode ini config file"
	exit -1
fi

if [ "$ProductionTestMode" = "yes" ];then
	if [ ! -d /mnt/mtd/Config/ ]; then
		mkdir -p /mnt/mtd/Config/
	fi
	
	touch /mnt/mtd/Config/ProductTestFeatureId
	
	FEATURE_ID=`cat $script_path/productionTestMode.ini | ./busybox grep ^\\s*featureId: | sed -e "s/\\s*featureId://g" -e "s/\r//g" -e "s/\n//g" -e "s/$(echo -e '\015')//g"`
	echo "FeatureId:$FEATURE_ID" > /mnt/mtd/Config/ProductTestFeatureId
fi

if [ "$productionTestMode" = "no" ];then
	rm -rf /mnt/mtd/Config/ProductTestFeatureId
fi
