#!/bin/bash

ping -c 2 www.energydt.cn
cd /home/pi/ebox-java

#获取最新版本号
curl -o latest https://www.energydt.cn/ebox-java/version
latest=`cat ./latest`
echo "latest: ${latest}"

# 获取当前版本
if [ -e ./version ];then
	version=`cat ./version`
else
	version="-1"
fi

echo "current version: ${version}"

if [ "$latest" != "$version" ];then
	curl -O "https://www.energydt.cn/ebox-java/ebox-java-${latest}.jar"
	cp ./latest ./version
fi

java \
	-jar \
	-Dspring.profiles.active=pro \
	-Ddb.name=ebox-lcy \
	-Dspring.rabbitmq.username=lcy \
	-Dspring.rabbitmq.password=lcy \
	-Dfile.encoding=utf-8 \
	-Duser.timezone=GMT+08 \
	-Duser.language=zh \
	-Xmx1024m \
	-XX:MaxDirectMemorySize=512m \
	"ebox-java-${latest}.jar"

