#!/bin/sh
paramServerUrl=$1

if [ ! -d "./config/" ];then
  echo "当前不是agent目录，退出更新"
  exit
else
  echo "当前是agent目录，开始更新"
fi

#sh stop.sh
currentdate=$(date +%Y%m%d)

echo "开始备份wglog-agent-release   ->   wglog-agent-release_$currentdate------"
mv wglog-agent-release "wglog-agent-release_$currentdate"
echo "wglog-agent-release备份完成"

echo "开始下载新的wglog-agent-release------"
curl -k -o wglog-agent-release "${paramServerUrl}/resources/wglog-agent-release"
echo "下载完成------"

echo "更新完成，开始重启agent------"

if test -x wglog-agent-release;
then
echo "准备启动agent------"
else
chmod +x wglog-agent-release
fi

sh start.sh
