#!/bin/bash 

#cd `dirname $0`
cd `dirname $0/.. >/dev/null 2>&1`
pwd_Home=`pwd`

##############################################################################

check(){
    if [ -d $pwd_Home/wechat ];then
        echo '····文件存在，开始部署'
    elif [ -f $pwd_Home/wechat.zip ];then
        echo '····解压企业微信包'
        unzip wechat.zip  >/dev/null 2>&1
    else
        echo -e "\033[41;30m wechat包不存在，请把包放到$pwd_Home下\033[0m"
        exit 1
    fi
}

install(){
    cd $pwd_Home/wechat
    echo "····修改脚本字符编码"
    chmod +x *.sh
    sed -i -e 's/\r//g' start.sh
    sed -i -e 's/\r//g' log4j.properties
    sed -i -e 's/\r//g' application.properties
    echo "····启动企业微信"
    sh $pwd_Home/wechat/start.sh
}


echo "【1】检测文件"
check
echo "【2】开始安装"
install
