#!/bin/sh
tarFileName=$1
paramStartPath=$2

echo "paramStartPath------${paramStartPath}"
echo "tarFileName------${tarFileName}"

dirName=${tarFileName//.tar.gz/}

echo "开始下载${tarFileName}------"
wget --no-check-certificate "https://www.wgstart.com/download/agentBackup/${tarFileName}"
echo "下载完成------"
tar -xvf ${tarFileName}
cd ./${dirName}/


if [ -n "$paramStartPath" ]; then
 echo "修改config/application.properties的配置项startPath------"
 sed -i "s#^startPath=.*#startPath=${paramStartPath}#g"  ./config/application.properties
fi
echo "修改完成------"

chmod +x start.sh

echo "部署下载已完成，开始启动AgentBackup------"
echo "开始检测wglcoud-agent进程的存活状态，如果发现wglcoud-agent进程不存在，则会自动启动agent------"
sh start.sh
