#ΦΈ¶¨·½·¨
zebracfgdir=/etc/zebracfg
webdumpdir=webdump
tarstrname=webdump.gz
#the parameter 1 is set zebracfg,1 is only open webdump.2 is all stblog
#0 is send  the webdump file to stb tools
#3 is clear all log settings
deletefile(){
if [ -f $zebracfgdir ];then
    echo "delete zebracfg";
    rm -rf $zebracfgdir;
fi
}
if [ $1 == "filestate" ];then
   if [ -f $zebracfgdir ];then
       exit 0;
   fi 
   exit 1;
fi
if [ $1 == "all" ];then
   deletefile;
   echo "webdump=1;" >>$zebracfgdir;
   echo "jsdebug=1;" >>$zebracfgdir;
   echo "debuginfo=1;" >>$zebracfgdir;
   exit 0;
fi
if [ $1 == "clearall" ];then
   deletefile;
   cd /var/;
   if [ -d $webdumpdir ];then
      rm -rf $webdumpdir;
   fi
   if [ -f $tarstrname ];then
      rm -rf $tarstrname;
   fi
   if [ ! -f $zebracfgdir ];then
       echo "webdump setting file is all cleared!!!";
   fi
   exit 0;
fi
if [ $1 == "senddata" ];then
   cd /var/
   if [ ! -d $webdumpdir ];then
       exit 1;
   fi
   echo "will tar  webdumpdata to $tarstrname";
   tar -cvf $tarstrname $webdumpdir;
   if [ ! -f $tarstrname ];then
       exit 1;
   fi
   if [ $2 == "" ];then
       exit 2;
   fi
   tftp -pr $tarstrname $2;
   exit 0; 
fi
exit 2;
