#!/bin/bash

ping -c 2 local.vrmaker.com.cn
cd /home/pi/ebox-java

#获取最新版本号
curl -o latest https://local.vrmaker.com.cn/ebox-java/localversion
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://local.vrmaker.com.cn/ebox-java/ebox-java-${latest}.jar"
	cp ./latest ./version
fi

JAVA_HOME=/opt/jdk1.8.0_181
export PATH=$PATH:$JAVA_HOME/bin

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

