#!/bin/sh

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

SoftIrSwitch=`cat $script_path/irSwitch.ini | ./busybox grep "softIrSwitch:" | ./busybox grep -v grep | sed 's/softIrSwitch://g' | sed 's/\r//g' | sed 's/\n//g' | sed "s/$(echo -e '\015')//g"`
if [ $? != 0 ]; then
	echo "cann't found SoftIrSwitch ini config file"
	exit -1
fi


if [ "$SoftIrSwitch" = "yes" ];then
	mkdir -p /mnt/mtd/Flags/
	touch /mnt/mtd/Flags/SoftPhotosensitiveFlag
	./playOrRecord -p 0 audio/softIrSwitch_Success.pcm
fi

if [ "$SoftIrSwitch" = "no" ];then
	rm -rf /mnt/mtd/Flags/SoftPhotosensitiveFlag
	./playOrRecord -p 0 audio/hardIrSwitch_Success.pcm
fi
