#!/system/bin/sh
configuration=$1;
file_path=$2;
webdumpdir=webdump
tarstrname=stblog.zip
savefile=`grep -r SAVE_TO_LOCALFILE=true /data/webkit_cfg`;


cd /data;

if [ $configuration = "all" ]; then
		busybox sed -i -e 's/SAVE_TO_LOCALFILE=false/SAVE_TO_LOCALFILE=true/' webkit_cfg;
		busybox sed -i -e 's/SAVE_TO_LOCALFILE=false/SAVE_TO_LOCALFILE=true/' data/com.zte.browser/webkit_cfg;
		busybox sed -i -e 's/MCSP_LOG=true/MCSP_LOG=false/' webkit_cfg;
		busybox sed -i -e 's/MCSP_LOG=true/MCSP_LOG=false/' data/com.zte.browser/webkit_cfg;		
		busybox sed -i -e 's/JS_DEBUG=false/JS_DEBUG=true/' webkit_cfg;
		busybox sed -i -e 's/JS_DEBUG=false/JS_DEBUG=true/' data/com.zte.browser/webkit_cfg;
		busybox sed -i -e 's/DEBUG_HTTP_LOG=false/DEBUG_HTTP_LOG=true/' webkit_cfg;
		busybox sed -i -e 's/DEBUG_HTTP_LOG=false/DEBUG_HTTP_LOG=true/' data/com.zte.browser/webkit_cfg;
		busybox sed -i -e 's/PRINT_INNERHTML_INNERTEXT=false/PRINT_INNERHTML_INNERTEXT=true/' webkit_cfg;
		busybox sed -i -e 's/PRINT_INNERHTML_INNERTEXT=false/PRINT_INNERHTML_INNERTEXT=true/' data/com.zte.browser/webkit_cfg;
        exit 0;
elif [ $configuration = "filestate" ]; then
       if [ ${savefile:="0"} != "0" ];then
	   exit 0;
	   else
	   exit 1;
	   fi
elif [ $configuration = "clearall" ]; then
        busybox rm -rf /data/"stblog"*.zip;
		busybox rm -rf /data/webkit_cfg; 
        exit 0;


elif [ $configuration = "senddata" ];then
   cd /var/
   if [ ! -d $webdumpdir ];then
       echo "the webdump file is empty!!!";
       exit 2;
   fi
   echo "will tar  webdumpdata to $tarstrname";
   zip -r $tarstrname $webdumpdir;
   if [ ! -f $tarstrname ];then
       echo "the $tarstrname is not exist!!!!";
       exit 2;
   fi
   tftp -pl $tarstrname $file_path;
   echo "the webdump was sended succeed!!!";
   exit 0; 
fi



