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

DISABLE_CFG=`cat $script_path/screen.ini | ./busybox grep "disable:" | sed 's/disable://g' | sed 's/\r//g' | sed 's/\n//g' | sed "s/$(echo -e '\015')//g"`
SCREEN_CFG=`cat $script_path/screen.ini | ./busybox grep "screen:" | sed 's/screen://g' | sed 's/\r//g' | sed 's/\n//g' | sed "s/$(echo -e '\015')//g"`
SCREEN_TIME_CFG=`cat $script_path/screen.ini | ./busybox grep "screen_time:" | sed 's/screen_time://g' | sed 's/\r//g' | sed 's/\n//g' | sed "s/$(echo -e '\015')//g"`


if [ "$DISABLE_CFG" = "yes" ]; then
	touch /mnt/mtd/Flags/DisableScreenFlag
elif [ "$DISABLE_CFG" = "no" ]; then
	[ -e "/mnt/mtd/Flags/DisableScreenFlag" ] && rm /mnt/mtd/Flags/DisableScreenFlag
fi

[ -e "/mnt/mtd/Flags/ScreenWorkTimeFlag" ] && rm /mnt/mtd/Flags/ScreenWorkTimeFlag
if [ "$SCREEN_CFG" = "yes" ]; then
	
	if [ "$SCREEN_TIME_CFG" = 0 ] ||
		[ "$SCREEN_TIME_CFG" = 30 ] ||
		[ "$SCREEN_TIME_CFG" = 60 ] ||
		[ "$SCREEN_TIME_CFG" = 120 ] ||
		[ "$SCREEN_TIME_CFG" = 180 ] ||
		[ "$SCREEN_TIME_CFG" = 240 ] ||
		[ "$SCREEN_TIME_CFG" = 300 ]
	then
		touch /mnt/mtd/Flags/initScreenWorkTimeFlag
		echo "ScreenWorkTime:$SCREEN_TIME_CFG" >> /mnt/mtd/Flags/ScreenWorkTimeFlag
	fi
else
	rm -f /mnt/mtd/Flags/initScreenWorkTimeFlag
	rm -f /mnt/mtd/Flags/ScreenWorkTimeFlag
fi