

#如果$1不存在 那么提示错误 并退出
if [ -z $1 ];then
    echo "please input project name;example: ./sync_res_hash_update.sh nba"
    exit
fi

#如果文件夹不存在 那么提示错误 并退出
if [ ! -d $1 ];then
    echo "$1 folder not exist"
    exit
fi

#如果hash文件不存在 那么提示错误 并退出
if [ ! -f "$1.hash" ];then
    echo "$1.hash not exist"
    exit
fi

#更新csv文件
csv=$1_CSV.js
rm -fr $1_CSV.js
svn export https://svn.5wufun.com:9443/svn/trunk/10conf/program/exe/CSV.js ./$csv

#如果csv文件不存在 那么提示错误 并退出  
if [ ! -f "$csv" ];then
    echo "$csv not exist"
    exit
fi

#执行比对
node $csv --folder_update ./$1

#如果zipfile文件夹不存在 那么创建文件夹
if [ ! -d "zipfile" ];then
    mkdir -p zipfile/$1
fi


#执行压缩
cd zipfile
tar -czvf $1.tar.gz ./$1
rm -fr $1
rm -f ../$csv