#!/bin/sh

lAudioTip=$1

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

echo  $script_path >> test
CUSTOM_APN_LIST=`cat $script_path/CustomApnList.ini | ./busybox grep "CustomApnList:" | ./busybox grep -v grep | sed 's/CustomApnList://g' | sed 's/\r//g' | sed 's/\n//g' | sed "s/$(echo -e '\015')//g"`
if [ $? != 0 ]; then
	echo "cann't found ProductionTestMode in config file"
	exit -1
fi
echo "CUSTOM_APN_LIST:$CUSTOM_APN_LIST"  
srcApnFile=$script_path/customApnList.json
dstApnFile=/mnt/mtd/Flags/customApnList.json
if [ "$CUSTOM_APN_LIST" = "yes" ]; then
	[ -e "$dstApnFile" ] && rm $dstApnFile
	
	if [ ! -d "/mnt/mtd/Flags/" ];then
		mkdir -p /mnt/mtd/Flags/
	fi
	
	cp $srcApnFile $dstApnFile
	if [ "$lAudioTip" != "no" ];then
		./simple_adec_bind_ao -r 8000 -t g711a -i audio/addCustomApn.pcm
	fi
	echo "cat $srcApnFile" >> test
elif [ "$CUSTOM_APN_LIST" = "no" ];then
	[ -e "$dstApnFile" ] && rm $dstApnFile
	if [ "$lAudioTip" != "no" ];then
		./simple_adec_bind_ao -r 8000 -t g711a -i audio/deleteCustomApn.pcm
	fi
fi





