#解压脚本
option=$1
date_dir=`date +%Y-%m-%d`
cd `dirname $0`

unZipWeb(){
    fileName=$1
    fileExt=$2

    echo "Start UnZip ... "$fileName
    rm -rf $fileName
    if [ "$fileExt" == "tar" ]; then
      tar -xf $fileName.$fileExt
    elif [ "$fileExt" == "zip" ]; then
      unzip -oq $fileName.$fileExt
    fi
    chmod 755 -R $fileName

    echo "Finish UnZip ... "$fileName
}

if [ "$option" == "agent_web" ]; then  
    unZipWeb "agent_web" "tar" 
elif [ "$option" == "agent_h5" ]; then    
    unZipWeb "agent_h5" "tar" 
elif [ "$option" == "game_web" ]; then
    unZipWeb "game_web" "tar"
elif [ "$option" == "phone_web" ]; then    
    unZipWeb "phone_web" "tar"
elif [ "$option" == "game_h5" ]; then    
    unZipWeb "game_h5" "zip"
elif [ "$option" == "game_egret_web" ]; then    
    # unZipWeb "game_egret_web" "tar"
    for fileName in `ls game_egret_web*tar`
    do
        base_name=${fileName%.*}
        unZipWeb $base_name "tar"
    done
elif [ "$option" == "game_egret_h5" ]; then    
    # unZipWeb "game_egret_h5" "tar"
    for fileName in `ls game_egret_h5*tar`
    do
        base_name=${fileName%.*}
        unZipWeb $base_name "tar"
    done
elif [ "$option" == "game_doc" ]; then    
    unZipWeb "game_doc" "zip"        
elif [ "$option" == "unity" ]; then   #官网
    unZipWeb "unity" "tar"
elif [ "$option" == "share" ]; then   #官网
    unZipWeb "share" "tar"
elif [ "$option" == "screen" ]; then  #截图
    unZipWeb "screen" "tar"
elif [ "$option" == "task_web" ]; then  #截图
    unZipWeb "task_web" "tar"
elif [ "$option" == "payment" ]; then  #截图
    unZipWeb "payment" "tar"               
# elif [ "$option" == "mobile" ]; then   #移动端热更新
#     echo "UnZip Client...mobile"
#     cp mobile_update.zip mobile_update.$date_dir.zip
#     rm -rf www
#     unzip -oq mobile_update.zip
#     chmod 755 -R www
fi