#!/bin/sh

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

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

DefaultVolumeset=`cat $script_path/DefaultVolume.ini | ./busybox grep "DefaultVolumeset:" | ./busybox grep -v grep | sed 's/DefaultVolumeset://g' | sed 's/\r//g' | sed 's/\n//g' | sed "s/$(echo -e '\015')//g"`
echo "DefaultVolume:$DefaultVolume,DefaultVolumeset : $DefaultVolumeset"
if [ $? != 0 ]; then
	echo "cann't found DefaultVolume ini config file"
	exit -1
fi
if [ "$DefaultVolumeset" = "yes" ]; then
		if [ "$DefaultVolume" -le "100" ] && [ "$DefaultVolume" -ge "0" ]; then
			mkdir -p /mnt/mtd/Flags/
			touch /mnt/mtd/Flags/initDefaultVolume
			echo "$DefaultVolume,$DefaultVolume" > /mnt/mtd/Flags/SupportDefaultVolumeFlag
			echo "valid DefaultVolume:$DefaultVolume" >> $script_path/test
			./simple_adec_bind_ao -r 8000 -t g711a -i audio/setDefaultVolumeSuccess.pcm
		else
			echo "invalid DefaultVolume:$DefaultVolume" >> $script_path/test
		fi
elif [ "$DefaultVolumeset" = "no" ]; then
	rm -f /mnt/mtd/Flags/initDefaultVolume
	rm -f /mnt/mtd/Flags/SupportDefaultVolumeFlag
fi
