#!/bin/sh

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

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

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

if [ "$HumanTrack" = "yes" ];then
	if [ ! -d "/mnt/mtd/FactoryCfg/" ];then
		mkdir -p /mnt/mtd/FactoryCfg/
	fi
	
	if [ -f "/mnt/mtd/FactoryCfg/Detect.fac" ];then
		rm -rf /mnt/mtd/FactoryCfg/Detect.fac
	fi
	
	cp -f humanTrack/Detect.fac /mnt/mtd/FactoryCfg/
	
	./simple_adec_bind_ao -r 8000 -t g711a -i audio/initHumanTrack.pcm
fi

if [ "$HumanTrack" = "no" ];then
	rm -rf /mnt/mtd/FactoryCfg/Detect.fac
	./simple_adec_bind_ao -r 8000 -t g711a -i audio/humanTrackDelete.pcm
fi
