#!/bin/sh

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

lAudioTipLanguage=$1

customApnList=`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 customApnList ini config file"
	exit -1
fi


if [ "$customApnList" = "yes" ];then
	mkdir -p /mnt/mtd/Flags/
	cp $script_path/customApnList.json /mnt/mtd/Flags/customApnList.json
	if [ $lAudioTipLanguage = "English" ];then
		./playOrRecord -p audio/addCustomApn_english.pcm -s 8000 -f 1
	else
		./playOrRecord -p audio/addCustomApn.pcm -s 8000 -f 1
	fi
fi

if [ "$customApnList" = "no" ];then
	rm -rf /mnt/mtd/Flags/customApnList.json
	if [ $lAudioTipLanguage = "English" ];then
		./playOrRecord -p audio/deleteCustomApn_english.pcm -s 8000 -f 1
	else
		./playOrRecord -p audio/deleteCustomApn.pcm -s 8000 -f 1
	fi
fi
